D daemon Active Member Licensed User Longtime User Sep 16, 2014 #1 The WebSocket client library has only one method, SendText, to send data to server. Is there any plan to support sending binary data (Byte array) such as binary file contents? Is that even there in specification? For now, I guess I should use ByteConverter and some sort of custom protocol?
The WebSocket client library has only one method, SendText, to send data to server. Is there any plan to support sending binary data (Byte array) such as binary file contents? Is that even there in specification? For now, I guess I should use ByteConverter and some sort of custom protocol?
Erel B4X founder Staff member Licensed User Longtime User Sep 16, 2014 #2 How are you implementing the server? Upvote 0
D daemon Active Member Licensed User Longtime User Sep 16, 2014 #3 Server will be Node.js websocket library. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 16, 2014 #4 The WebSocket client doesn't support binary transfers. If the file is small then you can encode it as base64 string. However for larger files it is recommended to use a standard http request. Otherwise you will block the single WebSocket connection. There is such an example in B4J that combines WebSocket with a standard handler: http://basic4ppc.com:51042/ (file upload with websockets). Upvote 0
The WebSocket client doesn't support binary transfers. If the file is small then you can encode it as base64 string. However for larger files it is recommended to use a standard http request. Otherwise you will block the single WebSocket connection. There is such an example in B4J that combines WebSocket with a standard handler: http://basic4ppc.com:51042/ (file upload with websockets).
D daemon Active Member Licensed User Longtime User Sep 16, 2014 #5 I tried with base64 encoding. It worked for small files of ~8KB. But for ~50KB file, my connection disconnects. I'm doing everything in may Main module but it continues to function. I do not get ANR. What could be wrong? I'm now trying to move some parts to a service. Upvote 0
I tried with base64 encoding. It worked for small files of ~8KB. But for ~50KB file, my connection disconnects. I'm doing everything in may Main module but it continues to function. I do not get ANR. What could be wrong? I'm now trying to move some parts to a service.
D daemon Active Member Licensed User Longtime User Sep 16, 2014 #6 OK, here is the reason specified in _Close event: Frame size of 65975 bytes exceeds maximum accepted frame size WebSockets connection lost WebSockets internal error (java.nio.channels.ClosedChannelException) How can I go beyond max limit? Upvote 0
OK, here is the reason specified in _Close event: Frame size of 65975 bytes exceeds maximum accepted frame size WebSockets connection lost WebSockets internal error (java.nio.channels.ClosedChannelException) How can I go beyond max limit?
D daemon Active Member Licensed User Longtime User Sep 16, 2014 #7 daemon said: OK, here is the reason specified in _Close event: Frame size of 65975 bytes exceeds maximum accepted frame size WebSockets connection lost WebSockets internal error (java.nio.channels.ClosedChannelException) How can I go beyond max limit? Click to expand... Never mind. Found that it was server configuration. It is working after changing server config maxReceivedFrameSize. https://github.com/Worlize/WebSocket-Node/wiki/Documentation However, it would be good if fragmentation was supported. Upvote 0
daemon said: OK, here is the reason specified in _Close event: Frame size of 65975 bytes exceeds maximum accepted frame size WebSockets connection lost WebSockets internal error (java.nio.channels.ClosedChannelException) How can I go beyond max limit? Click to expand... Never mind. Found that it was server configuration. It is working after changing server config maxReceivedFrameSize. https://github.com/Worlize/WebSocket-Node/wiki/Documentation However, it would be good if fragmentation was supported.
D daemon Active Member Licensed User Longtime User Sep 17, 2014 #8 I hit the wall again. For file size ~98KB with base64 encoding, I get following error: WebSockets internal error (de.tavendo.autobahn.WebSocketException: message payload exceeds payload limit) I see that the library has maximum payload size set to 131072 bytes (128 KB). May I request option to set it to a higher value? Upvote 0
I hit the wall again. For file size ~98KB with base64 encoding, I get following error: WebSockets internal error (de.tavendo.autobahn.WebSocketException: message payload exceeds payload limit) I see that the library has maximum payload size set to 131072 bytes (128 KB). May I request option to set it to a higher value?
Erel B4X founder Staff member Licensed User Longtime User Sep 17, 2014 #9 Try this: Code: Copy Dim jo As JavaObject = WebSocket1 jo = jo.GetField("options") 'WebSocketOptions jo.RunMethod("setMaxMessagePayloadSize", Array(4 * 1024 * 1024)) '4mb Call it before you connect. Upvote 0
Try this: Code: Copy Dim jo As JavaObject = WebSocket1 jo = jo.GetField("options") 'WebSocketOptions jo.RunMethod("setMaxMessagePayloadSize", Array(4 * 1024 * 1024)) '4mb Call it before you connect.
D daemon Active Member Licensed User Longtime User Sep 18, 2014 #10 Wow!!! This is cool and very interesting!! Thank you! Upvote 0