Websocket browser-to-Netburner length issue
Posted: Wed Mar 25, 2020 11:49 pm
Hi,
I have a Websocket connection to a Chrome browser.
When Netburner pushes data, all god, no issues whatsoever.
However, when I try to push data from the browser to Netburner, I get an issue with messages >125 bytes (first sending is ok, the rest is garbage until I re-establish the Websocket connection. If the messages are below 126 bytes, all is good).
Output from the below is:
(if I am sending 125 bytes)
Websocket_fd read_fds received len=125 first=30
Websocket_fd read_fds received len=125 first=30
Websocket_fd read_fds received len=125 first=30
Websocket_fd read_fds received len=125 first=30
(if I am sending 126 bytes)
Websocket_fd read_fds received len=126 first=30
Websocket_fd read_fds received len=134 first=B8
Websocket_fd read_fds received len=134 first=30
Websocket_fd read_fds received len=134 first=B8
void TaskWebInput(void *pd)
{
while(1)
{
fd_set read_fds;
FD_ZERO(&read_fds);
FD_SET(Websocket_fd, &read_fds);
if (select(FD_SETSIZE, &read_fds, (fd_set *)0, (fd_set *)0, TICKS_PER_SECOND * 5))
{
if (FD_ISSET(Websocket_fd, &read_fds))
{
char buffer[256];
memset(buffer, 0, sizeof(buffer));
int ret = read(Websocket_fd, buffer, sizeof(buffer));
iprintf("Websocket_fd read_fds received len=%i first=%02X\r\n", ret, buffer[0]);
}
}
}
}
On client side (triggered from a button that I push several times):
[125 bytes code]
var s="";
for(var i=0;i<12;i++)
s=s+"0123456789";
s=s+"01234";
ws.send(s);
console.log(s); // all the messages look perfectly fine in the log
[126 bytes code]
var s="";
for(var i=0;i<12;i++)
s=s+"0123456789";
s=s+"012345"; // just one more to get 126 bytes
ws.send(s);
console.log(s); // all the messages look perfectly fine in the log
Any ideas?
I have a Websocket connection to a Chrome browser.
When Netburner pushes data, all god, no issues whatsoever.
However, when I try to push data from the browser to Netburner, I get an issue with messages >125 bytes (first sending is ok, the rest is garbage until I re-establish the Websocket connection. If the messages are below 126 bytes, all is good).
Output from the below is:
(if I am sending 125 bytes)
Websocket_fd read_fds received len=125 first=30
Websocket_fd read_fds received len=125 first=30
Websocket_fd read_fds received len=125 first=30
Websocket_fd read_fds received len=125 first=30
(if I am sending 126 bytes)
Websocket_fd read_fds received len=126 first=30
Websocket_fd read_fds received len=134 first=B8
Websocket_fd read_fds received len=134 first=30
Websocket_fd read_fds received len=134 first=B8
void TaskWebInput(void *pd)
{
while(1)
{
fd_set read_fds;
FD_ZERO(&read_fds);
FD_SET(Websocket_fd, &read_fds);
if (select(FD_SETSIZE, &read_fds, (fd_set *)0, (fd_set *)0, TICKS_PER_SECOND * 5))
{
if (FD_ISSET(Websocket_fd, &read_fds))
{
char buffer[256];
memset(buffer, 0, sizeof(buffer));
int ret = read(Websocket_fd, buffer, sizeof(buffer));
iprintf("Websocket_fd read_fds received len=%i first=%02X\r\n", ret, buffer[0]);
}
}
}
}
On client side (triggered from a button that I push several times):
[125 bytes code]
var s="";
for(var i=0;i<12;i++)
s=s+"0123456789";
s=s+"01234";
ws.send(s);
console.log(s); // all the messages look perfectly fine in the log
[126 bytes code]
var s="";
for(var i=0;i<12;i++)
s=s+"0123456789";
s=s+"012345"; // just one more to get 126 bytes
ws.send(s);
console.log(s); // all the messages look perfectly fine in the log
Any ideas?