Well yes your absolutely on the right track.
Your parser expects a message that starts with byte 0x2 and ends with 0x3 .
In your testcase with
buffer.putLong(System.currentTimeMillis());
you are sometimes sending two consecutive 0x3 which
break your Protocol.
Then following scenario might happen in hasNextMessage():
start = -1
pos = 10
savedBuffer.limit()==10
So now hasNextMessage() == false
and isExpectingMoreData()==false
and hasMoreBytesToParse()== false
This causes Grizzly to not read any bytes of the wire on the selected connection
and your connection seems to pause and eventually because client keeps sending
bytes you see an exception.
if you make sure 0x2 and 0x3 won't be part of your message content you should
be fine...
> Thanks for you quick response.
>
> It will pause the paser if I the following code as client:
>
> for (int i = 0; i < 50000; i++) {
> try {
> ByteBuffer buffer = ByteBuffer.allocate(16);
> buffer.put(new byte[]{0x02});
> buffer.putLong(System.currentTimeMillis());
> buffer.put(new byte[]{0x03});
> buffer.flip();
>
> connectorHandler.write(buffer, false);
> Thread.currentThread().sleep(50L);
> if (i%10 == 0) System.out.println("i = " + i);
> } catch (Exception e) {
> System.out.println("Exception in execute ... " + e);
> e.printStackTrace(System.out);
> break;
> }
> }
>
> It seems that some byte value will pause the parser.
>
> Attached my client code:
>
> http://www.nabble.com/file/p18776606/MyClient.java MyClient.java
>
> --
> View this message in context:
> http://www.nabble.com/java.io.IOException%3A-An-existing-connection-was-forcibly-closed-by-the-remote-host-tp18739932p18776606.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
--
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196