andremussche / DelphiWebsockets

Websockets and Socket.io for Delphi
251 stars 129 forks source link

fixed "Invalid frame continuation" exception when ping or pong frames arrive while also fragmented data frames are being received #29

Open mca0815 opened 7 years ago

mca0815 commented 7 years ago

Fixed a possible Invalid frame continuation. Data = ... exception in TIdIOHandlerWebsocket.ReadMessage:

When a large message is being received that comes in as several fragments, it may happen that a wdcPong is also received inbetween of the fragments. This results in bFIN being true and the function being leaved. When the function is entered again for the next fragment, lFirstDataCode is wdcNone. This results in the exception being thrown in the wdcContinuation of the case statement.

Solution: Reset bFIN to false and therefore ignore the wdcPong as long as were are still receiving fragments. My client doesn't send pings so I didn't see it in my scenario but the same should apply for wdcPing frames.

arvanus commented 6 years ago

Just a question, are you using the client with socket.IO, or just websocket? I`not sure how to use with just a websocket server... Thanks!