SocketIO Chrome Inspector Frames

2019-04-10 23:07发布

I was playing around with Socket.IO and ran into some questions when viewing the frames in the chrome inspector.

enter image description here

What do the numbers beside each frame's content mean?

1条回答
在下西门庆
2楼-- · 2019-04-10 23:50

That's the Engine.io protocol where the number you see is the packet encoding:

<packet type id>[<data>]

example:

2probe

And these are the different packet types:

0 open

Sent from the server when a new transport is opened (recheck)

1 close

Request the close of this transport but does not shutdown the connection itself.

2 ping

Sent by the client. Server should answer with a pong packet containing the same data

example 1. client sends: 2probe 2. server sends: 3probe

3 pong

Sent by the server to respond to ping packets.

4 message

actual message, client and server should call their callbacks with the data.

example 1

server sends: 4HelloWorld client receives and calls callback socket.on('message', function (data) { console.log(data); });

example 2

client sends: 4HelloWorld server receives and calls callback socket.on('message', function (data) { console.log(data); });

5 upgrade

Before engine.io switches a transport, it tests, if server and client can communicate over this transport. If this test succeed, the client sends an upgrade packets which requests the server to flush its cache on the old transport and switch to the new transport.

6 noop

A noop packet. Used primarily to force a poll cycle when an incoming websocket connection is received.

example

client connects through new transport client sends 2probe server receives and sends 3probe client receives and sends 5 server flushes and closes old transport and switches to new.

You can read the full documentation here

查看更多
登录 后发表回答