user551761
user551761

Reputation:

Java & JavaScript WebSockets

I've created a Java & JavaScript application using WebSockets. For the Java server I'm using the following library: https://github.com/TooTallNate/Java-WebSocket.

So about the application:

First, the session begins with two messages. The first one is sent from the browser and the second one is a reply from the Java server. After that, the Java server starts with sending messages at 50 ms intervals. The messages are pretty big (about 500 KB each).

When I try to send a message back from the browser to the server the client just stops receiving messages. Nothing happens, not even calling the onclose, onerror callbacks of the WebSockets API (on both sides client and server). I checked the network in the chrome dev tools and nothing unusual happens; I just stop receiving messages from the server...

Can you give me any idea of what the problem could be?

Upvotes: 2

Views: 726

Answers (2)

user1073461
user1073461

Reputation:

The problem is because the output stream of the server blocks.

Usually you can fix it by doing the output in separate thread.

Upvotes: 2

Minko Gechev
Minko Gechev

Reputation: 25682

I've got similar problem and just fixed it before few days. Just put the stream from the server in different thread. This is going to resolve all issues.

Upvotes: 2

Related Questions