dongsong1911
2015-07-07 08:30
浏览 655
已采纳

Gorilla WebSocket与golang.org/x/net/websocket的比较

According Gorilla Websockets Project it is not possible to send pings and pongs using golang.org/x/net/websocket. At the same time, the following is on the project page of golang.org/x/net/websocket:

Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455.

I am a little confused. golang.org/x/net/websocket implements RFC 6455 but can not send control frames (cancel, ping, pong) although this is specified in RFC 6455 - Section Control Frames

So what will happen if I use golang.org/x/net/websocket package. Will the connection abort after a timeout? In other words, how is it ensured here that the connection does not break off.

图片转代码服务由CSDN问答提供 功能建议

根据 Gorilla Websockets项目,无法使用 golang.org/x/net/websocket 发送ping和pong。 同时,以下内容在 golang.org/x/net/的项目页面上 websocket

软件包websocket为RFC 6455中指定的WebSocket协议实现了客户端和服务器。 \ n

我有点困惑。 golang.org/x/net/websocket 实现RFC 6455,但是尽管在 RFC 6455-部分控制框架

所以,如果我使用 golang.org / x / net / websocket 软件包。 超时后连接会中止吗? 换句话说,在这里如何确保连接不会中断。

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongse7261 2015-07-07 11:26
    已采纳

    According Gorilla Websockets Project it is not possible to send pings and pongs using golang.org/x/net/websocket

    The Gorilla README says something different. It says that the golang.org/x/net package cannot send a ping or receive a pong. It does not say that the package will not send a pong.

    The golang.org/x/net package automatically responds to a ping received from the peer by sending a pong to the peer, as does the Gorilla package. Both packages work correctly with a peer that's using ping and pongs to keep the connection alive.

    An application that uses the golang.org/x/net/websocket package cannot employ pings and pongs to keep the connection alive. There's no way to send the ping. There's no way to detect that the pong was received.

    点赞 评论

相关推荐 更多相似问题