Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Sharing/Binding a java.net.Socket among HTTP threads initialized by Jetty server

1 Socket == 1 Connection == 1..n HTTP requests

With HTTP/1.1 and pipelining you can serve multiple requests on that 1 connection.
Pipelining does this via sequential requests/responses on that same connection.

You'll want to ensure you are using HTTP pipelining correctly.

Now, for the future, there's HTTP/2 with multiplexed connections.
That can handle multiple request/responses on the same connection at the same time, interleaving them.
But that's not a finalized standard yet (its close, and we have an implementation on our jetty-http2 branch)

Finally, "SocketException: broken pipe" means that the connection was gracefully closed by the remote endpoint, you usually see this when a socket.write is attempted.
Again, if you see this on your client side, then you are likely either not using pipelining correctly, or have a non-compliant http client.
There is nothing special you have to do / configure / enable pipelining on Jetty, it's always available.


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Fri, Aug 29, 2014 at 8:17 AM, Behrooz Nobakht <nobeh5@xxxxxxxxx> wrote:
Hi,

I am developing a simple Jersey + Jetty REST service in which to complete a request, it is needed to send/receive through a java.net.Socket. The socket is initialized during application start-up.

What I'm observing is that although the socket is verified to work as expected in the start-up, during the runtime of the service, trying to complete an arbitrary HTTP request, an exception is thrown which is basically "SocketException: broken pipe". My guess is that most likely the Socket instance is not accessible through different HTTP threads. 

Is this correct? And, what would be the best practice at least from Jetty perspective to have a shared Socket among different HTTP request threads?

Thanks,
Behrooz


_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-dev


Back to the top