mongoose-cpp icon indicating copy to clipboard operation
mongoose-cpp copied to clipboard

Error 1006, JS gets disconnected when CPP sends data

Open benkuper opened this issue 5 years ago • 0 comments

Hello, I'm testing juce_mongoose, which is a direct port of mongoose-cpp (I checked that the code is the same for this issue).

When testing the websocket example - I modified it a bit to send 10 messages in a row instead of just one -, the websocketReady function gets called at every new message, but the websocketdata gets called randomly (2 times out of 100). I tried to trace back a bit and it seems that the function "event_handler" (Server.cpp line 39) gets called at every message, and then the "websocketReady" gets called immediately. This then goes into Websockets::add and it replaces the previous connection all the time.

I'm not sure what should be done, but I would expect that webSocketready gets only called once, and then websocketdata gets called for all the incoming data, right ?

On the browser side, the Websocket is behaving "normally", meaning that it detects a connection at first, sends the message, receive some. Though it receives a disconnection in the end even though I didn't close the websocket on the cpp side...

Also, in websocketReady , the getId() return -1.

Thanks !

benkuper avatar Jun 17 '20 10:06 benkuper