Comments (9)
@xXLokerXx @majidbigdeli There is no issue with neffos at all, you don't need to delete a header or things like that, this happesn only on Gorilla websocket upgrader because it has a CheckOrigin field which by-default allows only same-origin. So the solution is to modify that to allow everything - you don't need to catch anything there - neffos + cors will do the job. The gorilla websocket's check origin is type of:
func (r *http.Request) bool
Example Code:
import "github.com/kataras/neffos"
import "github.com/kataras/neffos/gorilla"
import gorillaWs "github.com/gorilla/websocket"
// [...]
websocketServer := websocket.New(
gorilla.Upgrader(gorillaWs.Upgrader{CheckOrigin: func(*http.Request) bool{return true}}),
serverEvents)
Hope that helped!
from neffos.
@kataras yes . Gorilla websocket upgrader has a CheckOrigin field . Thank you.
from neffos.
@majidbigdeli I know that you are using websockets+cors middleware, so I have to ask you too, do you have the same issue with cors on websockets?
from neffos.
@kataras I have not issue with cors .
from neffos.
@xXLokerXx please change websocket.DefaultGorillaUpgrader
to websocket.DefaultGobwasUpgrader
it is work .
from neffos.
WebSocket connection to 'ws://localhost:3001/echo?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjozMjEzMjF9.8waEX7-vPKACa-Soi1pQvW3Rl8QY-SUFcHKTLZI4mvU' failed: Error during WebSocket handshake: Unexpected response code: 403
it issue related to DefaultGorillaUpgrader in my test .
with DefaultGobwasUpgrader it is work .
from neffos.
Yes, that help me a lot, i'll implement right now
thanks @kataras and @majidbigdeli
im really thankfully for help
from neffos.
You are welcome @xXLokerXx of course!
from neffos.
it works.
@xXLokerXx @majidbigdeli There is no issue with neffos at all, you don't need to delete a header or things like that, this happesn only on Gorilla websocket upgrader because it has a CheckOrigin field which by-default allows only same-origin. So the solution is to modify that to allow everything - you don't need to catch anything there - neffos + cors will do the job. The gorilla websocket's check origin is type of:
func (r *http.Request) boolExample Code:
import "github.com/kataras/neffos" import "github.com/kataras/neffos/gorilla" import gorillaWs "github.com/gorilla/websocket" // [...] websocketServer := websocket.New( gorilla.Upgrader(gorillaWs.Upgrader{CheckOrigin: func(*http.Request) bool{return true}}), serverEvents)Hope that helped!
it works.
from neffos.
Related Issues (20)
- When there is no data transmission for 60 seconds, neffos automatically triggers the disconnection. I don’t want this, I need to disconnect manually HOT 1
- How to modify the format of websocket response
- How to send heartbeat to client?
- [FEATURE REQUEST]How to establish a websocket connection similar to neffos using Android
- [BUG][HELP] Will frequent use of Broadcast methods cause block? HOT 1
- fatal error: concurrent map iteration and map write HOT 1
- [BUG] redis.NewStackExchange got radis err: NOAUTH Authentication required. HOT 1
- [BUG] The Message.FromStackExchange field do not perform as expected when using StackExchange
- Is neffos.Conn.Socket().WriteText() Atomic? HOT 2
- [BUG] Socket missed a lot of msgs HOT 3
- [BUG] Broadcast deadlocks when concurrency HOT 2
- How incoming connections to join room `chat` ?
- [BUG] basic in example, broswer message must be sent twice
- Do we have C# Client to connect form Unity Game Engine[FEATURE REQUEST] HOT 1
- how to react on native mode when a client or a server disconnected
- How to connect client to server?
- How to assign some values to a socket connection?
- [BUG] client how do reconnect?
- [BUG] how to recover program
- [FEATURE REQUEST] use stackexchange only Broadcast text msg?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neffos.