Igor Soarez
Igor Soarez

Reputation: 6822

Continuation frame cannot follow current opcode

I'm using ws in a Node websocket server.

In production, I frequently get this error:

Error: continuation frame cannot follow current opcode

What is causing this?

How should go about debugging and replicating this error in a development environment?

EDIT:

Doesn't seem to be specific to a browser, I've captured these errors in connections from Chrome, Firefox and IE10 and from different operating systems.

EDIT 2:

Error is thrown here. Apparently after receiving a frame with opcode 0 after a frame with a code != 1 && != 2.

EDIT 3:

RFC6455, section 5.2, shows what the opcodes mean and the frame's anatomy.

Upvotes: 2

Views: 759

Answers (3)

Ted W
Ted W

Reputation: 248

I started seeing this error, and it was caused by this code in my server.js:

wss.on('connection', function (client, request) {
    wsg = client;
    client._socket.setEncoding('utf8'); // <== oops, don't do this
    // ...
}

Upvotes: 0

oberstet
oberstet

Reputation: 22051

You might run Autobahn Testsuite (in fuzzing client mode) against your server. This will give you a detailed report like this (including wirelogs) of issues encountered.

Disclosure: I am original author of Autobahn and work for Tavendo.

Upvotes: 2

AronVietti
AronVietti

Reputation: 379

For a continuation frame to work the frame before it needs to be a continuation frame or an initial frame of 1/text or 2/binary. So a frame that is not a continuation, text or binary frame is being sent. Or a new text or binary frame is being sent before it should.

To debug you need to analyze the code on the client side and check the frames on the sever side to figure out why it's sending frames out of order.

Upvotes: 1

Related Questions