2

I apologize for the vague question title, but I can't think of a better way to describe the issue.

I'm connecting to a socket.io server (netty) using redannick's FlashSocket.IO library

Everything (connection, handshake, protocol upgrade) seems to work correctly, but when it comes time to start sending/receiving messages, I'm noticing an odd trend: all of the responses to my messages are behind by 1.

The most basic example I can give is that I have to send two PINGs before I receive a single PONG, and the PONG that I do receive is actually a response to the first PING.

A more detailed example: I send a message with a room ID. This message is supposed to receive a response in the form of "room-ID activated." I will not receive that response until after another message is sent from the server.

I can force the server to send another message by following the room ID message with a PING. This triggers a PONG sent from the server, but the only message I receive on the client side is the "room-ID activated" message.

I have a feeling the problem lies somewhere within the FlashSocket.IO library, but I'm not sure exactly where to look. I know for a fact that the server is sending all the messages it's supposed to send because I have a test app written in JavaScript using socket.io's client and it works as expected.

Marcela
  • 3,728
  • 1
  • 15
  • 21
  • The first think I can think of, is not getting the proper "package end". So you get a response, but it's not converted to true one, and it's buffered inside client. The time you got second, it somehow manages to parse the first one, and buffers the second. Currently I cannot test it, I'll do it later, but the best thing to do is to try to debug `onSocketData` in `WebSocket.as`, then precisely check what are you sending from server. Good luck! – Andrey Popov Jun 04 '15 at 06:05
  • 1
    And this is an issue in the original repo (that FlashSocket.IO is forked from): https://github.com/simb/FlashSocket.IO/issues/27 – Andrey Popov Jun 04 '15 at 06:16
  • Andrey, I kind of thought the same thing, so I put a breakpoint and trace statements in `WebSocket.onSocketData`, but I wasn't seeing anything that would suggest it was receiving/buffering data. – Marcela Jun 04 '15 at 13:37
  • First put breakpoint at line 308 (`if (headerState == 4) {`) as it modifies the buffer. Next - 318 (`if (frame) {` - check whenever there is **no** frame - this means it goes to the buffer. Log what's going on. – Andrey Popov Jun 04 '15 at 14:27
  • I actually put a breakpoint at line 295 (first line of `onSocketData`, and the only thing that comes in after I send the room ID is a "6" (noop), which I assume is a response to the "5" that `FlashSocket` automatically sends when it receives the `3probe` message from the server. I'm really hoping this isn't some form of incompatibility between the FlashSocketIO library and the socket.io version on the server (1.3.5) – Marcela Jun 04 '15 at 18:48

0 Answers0