Code Monkey home page Code Monkey logo

Comments (5)

eynzhang avatar eynzhang commented on June 11, 2024

@titilami thanks for the feedback, I had a look the source code of websocket and I think we can find a solution. I will do more test and fix this.

from huobi_golang.

titilami avatar titilami commented on June 11, 2024

@eynzhang thx, i have multi goroutines to send websocket request. These goroutines may call WebSocketClientBase.conn.WriteMessage simultaneous at sometime
.

from huobi_golang.

eynzhang avatar eynzhang commented on June 11, 2024

@titilami I think we need to handle it ourselves in SDK, the gorilla websocket doesn’t support concurrent write message, see below words from their documentation:

https://github.com/gorilla/websocket/blob/master/doc.go

Concurrency

Connections support one concurrent reader and one concurrent writer.

Applications are responsible for ensuring that no more than one goroutine
calls the write methods (NextWriter, SetWriteDeadline, WriteMessage,
WriteJSON, EnableWriteCompression, SetCompressionLevel) concurrently and
that no more than one goroutine calls the read methods (NextReader,
SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler)
concurrently.

The Close and WriteControl methods can be called concurrently with all other
methods.

from huobi_golang.

eynzhang avatar eynzhang commented on June 11, 2024

@titilami please get the lates update from master branch, the mutex is introduced to support concurrently subscribing. I tested it and it works well. You can refer to the new added traderexample.

from huobi_golang.

titilami avatar titilami commented on June 11, 2024

@eynzhang thx.

from huobi_golang.

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.