websocket protocol issue

Hi -

I am using the libray ArduinoHttpClient library 0.3.1 for its websocket functionality.

There is a nodejs websocket server sending a json message every 5 seconds or so to a mkr1010 .
The arduino code below checks the websocket client every 250ms (timed by an interrupt) and I then just print the message.

Periodically the arduino receives this type of message:

-WebSocket-Accept: IITLDv8iKA224HKPdqHoDvdkhWQ=
Sec-WebSocket-Protocol
(often truncated or pieces are garbled)

...which looks very much like a server request to the arduino http client requesting a websocket upgrade even though the websocket is already connected and running.
The nodejs websocket server then kills the connection with the error message: 1006 Socket Error: read ECONNRESET. And finally the arduino serial port seems to lock up and I have to repower it.

Can anybody suggest where to look to find out what this is and how to fix it?

Thanks, John.

void TC5_Handler (void) {
if (client.connected()) {
int messageSize = client.parseMessage();
if (messageSize > 0) {
tmpMessage = client.readString();
tempMsg = true;
}
}
}

void loop() {
if (tempMsg) {
Serial.println(millis());
Serial.println(tmpMessage);
tempMsg = false;
}
}

Okay it seems that there is an interrupt conflict happening somewhere most likely.
The issue goes away when using a simple millis() based counter to check every 250ms.

The challenge I have is that I need to service the inbound messages with upmost priority and polling like this is not ideal.

Any ideas how to service an inbound websockets message queue that takes priority over everything else?

The arduino code below checks the websocket client every 250ms (timed by an interrupt) and I then just print the message.

Wrong, that code does nothing, it doesn't even compile. I guess you made some excerpt but that just wastes our time. Post complete code. If you think your code is too large, make a shorter version that still shows the same symptoms. And if you use external libraries post links to them.