Comments (8)
Could you set the FleckLog.LogLevel to debug and attach the output here?
On May 20, 2012 10:35 PM, "arct" <
[email protected]>
wrote:
When testing the jWebSocket Android client "fundamental" demo apk, the
client can connect with Fleck, but closes the connection upon sending a
message. No onMessage event is fired at the Fleck server.
Reply to this email directly or view it on GitHub:
#41
from fleck.
5/21/2012 6:46:20 PM [Info] Server started at ws://localhost:8080 (Fleck server started)
5/21/2012 6:46:23 PM [Debug] Client Connected (jWebsocket Android client opens connection)
5/21/2012 6:46:23 PM [Debug] 236 bytes read
5/21/2012 6:46:23 PM [Debug] Building Hybi-14 Response
5/21/2012 6:46:23 PM [Debug] Sent 129 bytes (Fleck server waits for message)
5/21/2012 6:46:28 PM [Debug] 69 bytes read (jWebSocket Android client sends message)
5/21/2012 6:46:28 PM [Debug] Error while reading Fleck.WebSocketException: Exception of type 'Fleck.WebSocketException' was thrown.
at Fleck.Handlers.Hybi13Handler.ReceiveData(List1 data, ReadState readState, Action
2 processFrame)
at Fleck.Handlers.Hybi13Handler.<>c__DisplayClassa.b__5(List1 d) at Fleck.Handlers.ComposableHandler.Receive(IEnumerable
1 data)
at Fleck.WebSocketConnection.<>c__DisplayClassb.b__a(Int32 r)
at Fleck.SocketWrapper.<>c__DisplayClassb.b__9(Task1 t) at System.Threading.Tasks.Task
1.<>c__DisplayClass17.b__16(Object obj)
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
5/21/2012 6:46:28 PM [Debug] Sent 4 bytes (jWebsocket Android client closes connection)
from fleck.
The source of the exception is this line. It's designed to ensure that an incoming frame is valid. If an invalid frame is received, an exception is thrown and the connection is closed.
if (!isMasked
|| !Enum.IsDefined(typeof(FrameType), frameType)
|| reservedBits != 0 //Must be zero per spec 5.2
|| (frameType == FrameType.Continuation && !readState.FrameType.HasValue))
throw new WebSocketException(WebSocketStatusCodes.ProtocolError);
It's not passing one of the checks. It's possible that jWebsocket isn't matching spec. I would say that dropping a breakpoint on this conditional and finding the failing expression would be your best bet as to determining the cause of the error. Would you mind doing that?
from fleck.
I added watches for each operand in that expression and set a breakpoint there. After stepping through to the exception, they evaluated as follows:
!isMasked : TRUE
!Enum.IsDefined(typeof(FrameType), frameType) : FALSE
reservedBits != 0 : FALSE
(frameType == FrameType.Continuation && !readState.FrameType.HasValue) : FALSE
WebSocketStatusCodes.ProtocolError = 1002
It appears jWebSocket Android client does not mask frames when sending. That's probably the culprit, because I don't think that's compliant behavior per RFC 6455. Am I correct?
from fleck.
That's correct. RFC 6455 states both of the following:
If the data is being sent by the client, the frame(s) MUST be masked as defined in Section 5.3.
The server MUST close the connection upon receiving a frame that is not masked.
If you're interested in helping jWebSocket, the masking algorithm is quite simple, and a C# implementation exists here.
public static byte[] TransformBytes(byte[] bytes, int mask)
{
var output = new byte[bytes.Length];
var maskBytes = BitConverter.GetBytes(mask);
if (BitConverter.IsLittleEndian)
Array.Reverse(maskBytes);
for (int i = 0; i < bytes.Length; i++)
{
output[i] = (byte)(bytes[i] ^ maskBytes[i % 4]);
}
return output;
}
from fleck.
Thank you for your help.
from fleck.
Has this problem been solved? Because I see the same problem now. .
from fleck.
the issue seemed to be with jwebsocket. best to check there.
from fleck.
Related Issues (20)
- Handshake SupportedSubProtocols does not work. HOT 3
- How to find out how many connections are connected to a websocket? HOT 1
- Slow Connection Times?
- net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH HOT 2
- Disposing the server when RestartAfterListenError is true may result in a restarted socket
- Memory leak when sending from the server. HOT 1
- Is this project abandoned? HOT 3
- How to get the websocket connecting a client in server.start() HOT 2
- Question: SSL Client Certificate difference HOT 4
- How to let the session close at end of the prosess by OnMessage, disable.
- Server cannot receive binary data with OnBinary if there is OnMessage
- Custom CipherSuite
- Garbled messages from server
- RobiniaDocs API Explorer
- Hi, boss , why don't upgrade new version of Fleck? thx.
- maximum received message size?
- How to stop this websocket service? HOT 1
- How do I close non-websocket connections?
- WebSocketConnetction.SendBytes([]) possible null reference when this.Socket is null
- Write a method to let it not log the information?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fleck.