Giter Club home page Giter Club logo

golang-socketio's Introduction

Golang Socket.IO

This library was forked from github.com/graarh/golang-socketio

It provides a simple Golang implementation of socket.io client and server.

The code was heavily refactored, also implemented XHR polling transport for client and server upgrade XHR -> websocket.

Pull requests appreciated

Usage examples

Please observe the examples directory for usage examples:

JavaScript client:    examples/assets/index.html, serve it with:
Go server:            go run examples/server/server.go

Go client via WS:     go run examples/client_websocket/client.go
Go client via XHR:    go run examples/client_xhr_polling/client.go

Please note that no Go client upgrade implemented yet.

This client is mainly for testing purposes.

Installation

go get github.com/mtfelian/golang-socketio

TODOs, ideas to further development

  • write tests, make a good test coverage
  • Go client's upgrade from XHR to WS
  • Go server's ability to fallback from WS to XHR
  • Go client's ability to fallback from WS to XHR
  • support newer versions of socket.io protocol

golang-socketio's People

Contributors

graarh avatar mtfelian avatar nkawa avatar varun1729 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

golang-socketio's Issues

Immediate dissconnect due to non UTF bytes in connect response

Hi! I'm trying to connect to api.victra.io/stream and got response with weird bytes attached to body 😢

base64

AAEACf8weyJzaWQiOiI3OTkzMjg2NmNlY2M0MTUyYThlYjEzZWQ4NmQ3NjAxZSIsInVwZ3JhZGVzIjpbIndlYnNvY2tldCJdLCJwaW5nVGltZW91dCI6NjAwMDAsInBpbmdJbnRlcnZhbCI6MjUwMDB9AAL/NDA=

raw

�	ÿ0{"sid":"79932866cecc4152a8eb13ed86d7601e","upgrades":["websocket"],"pingTimeout":60000,"pingInterval":25000}�ÿ40

But JavaScript or Python clients works just fine

Could not figure out how to completly remove this from response

Don't process incoming message asynchronously

Just a heads-up with an issue that happened with me.

golang-socketio/channel.go

Lines 156 to 158 in 90487b6

default:
go e.processIncoming(c, decodedMessage)
}

isn't correct because sometimes you want to have a guarantee on the order of incoming messages.

Instead, you want to guarantee the order like so:

https://github.com/wedeploy/gosocketio/blob/ef257277a67693f4f0830594e3829e3e02c4d402/client.go#L257-L259

and let the consumer decides if he swaps a new goroutine for handling the message or handles it on the same one.

If you go to https://asciinema.org/a/192043 (between 1:57 and 2:15) and you see the execution of some shell commands you get why this is fundamental (every key you hit on the keyboard is an event).

wss connection problem / bad handshake

x509: certificate is valid for <localhost>, not <remote host>

Any ideas on what may be causing this?
I am connecting using the wss protocol.
Connecting like so:
client, err := gosocketio.Dial("wss://"+host+"/test/socket.io", transport.DefaultWebsocketTransport())

I wont't be surprised if this is a Docker issue with my remote host... and not on golang-socket.io side...

Installing handlers before connecting

Hi.

I'm looking into socketio libraries to choose one, so I haven't used this yet.

Using gosocketio.Dial to create a client immediately connects, before I've had a chance to install handlers. Is there a way to install handlers before the connection occurs, so we're certain my handlers can see every incoming message?

Why HTTP code 403 when upgrading to websockets?

Hi. I'm trying to use your lib with gin, so I've set up a server , and trying to connect with javascript client using latest socket.io-client package. It works only on transport "polling". When trying to upgrade to web sockets, it shows next:

image

My server code:

package main

import (
	"github.com/gin-gonic/gin"
	"github.com/mtfelian/golang-socketio"
)

func main() {
	router := gin.Default()
	sio := gosocketio.NewServer()
	router.GET("/socket.io/", gin.WrapH(sio))
	router.POST("/socket.io/", gin.WrapH(sio))
	router.Run(":7000")

}

When I use latest socket.io server on NodeJS, it upgrades fine.

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.