Coder Social home page Coder Social logo

Comments (5)

lesismal avatar lesismal commented on June 6, 2024

Websocket的Message是有多种类型的(Text/Binary/Ping/Pong),直接Write不包括类型信息,框架如果默认使用某个类型是不合理的。
error信息已经表述比较明确了,请使用 WriteMessage

from nbio.

lesismal avatar lesismal commented on June 6, 2024

如果代理转发目标server也是websocket、握手后只需要透传数据,还可以参考这里的方式减少websocket协议的解析与组装来提高转发效率:
#205

from nbio.

lesismal avatar lesismal commented on June 6, 2024

这段代码,是想把req发送给一个Websocket.Conn?这本身就不合理吧。
完整一点的代码或者功能描述给出来才能明白OP你具体想做什么。

如果是想req去send websocket握手请求,不是非要这样做的,可以直接用nbio的websocket.Dial,这里有例子:
https://github.com/lesismal/nbio-examples/blob/master/websocket/nbioclient/client.go

from nbio.

pippozq avatar pippozq commented on June 6, 2024

我只是想问问没有实现Writer 接口的考虑,现在知道你的考虑点了,我就用writeMessage方法吧

from nbio.

pippozq avatar pippozq commented on June 6, 2024

我看了下那两个链接的代码,对于我现有代码改动比较大吧,因为我是替换gorilla的websocket,我现在直接用WriteMessage的话,dump一次request就行,没啥大的改动。把req发送给websocket.conn ,比如远端集群禁入,但是出网可以通过白名单,那我就可以在远端启动一个client,然后到中心建立一个websocket,中心端访问远端集群的服务HTTP接口就通过这个隧道了,也只是转发http的请求不转发其他流量,所以是这么来考虑的,这个问题我先关闭了哟,后续有问题再请教

from nbio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.