Comments (13)
I see this issue in 1.5.1, I don't know the exact reason, though it is possible my automatic ping code tries to send a ping message even though the connection was closed. Wonder if there is a definitive way to know if the connection has closed ?
Feb 13 21:55:18 Hub: panic: runtime error: invalid memory address or nil pointer dereference
Feb 13 21:55:18 Hub: [signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x3863ec]
Feb 13 21:55:18 Hub: goroutine 301 [running]:
Feb 13 21:55:18 Hub: github.com/valyala/fasthttp.(*hijackConn).SetWriteDeadline(0x0?, {0x40025e720c?, 0x40025cf628?, 0x0?})
Feb 13 21:55:18 Hub: <autogenerated>:1 +0x2c
Feb 13 21:55:18 Hub: github.com/fasthttp/websocket.(*Conn).write(0x40023bef20, 0x9, {0x40001869e0?, 0x400349f800?, 0x0?}, {0x40025e720c, 0x2, 0x402}, {0x0, 0x0, ...})
Feb 13 21:55:18 Hub: /home/om26er/go/pkg/mod/github.com/fasthttp/[email protected]/conn.go:416 +0x190
Feb 13 21:55:18 Hub: github.com/fasthttp/websocket.(*messageWriter).flushFrame(0x4002837ec8, 0x1, {0x0?, 0x19b2c?, 0x4003227748?})
Feb 13 21:55:18 Hub: /home/om26er/go/pkg/mod/github.com/fasthttp/[email protected]/conn.go:661 +0x360
Feb 13 21:55:18 Hub: github.com/fasthttp/websocket.(*Conn).WriteMessage(0x40023bef20, 0x448a48?, {0x0, 0x0, 0x0})
Feb 13 21:55:18 Hub: /home/om26er/go/pkg/mod/github.com/fasthttp/[email protected]/conn.go:815 +0xfc
Feb 13 21:55:18 Hub: github.com/code/connect/transport.(*FastHTTPPeer).Ping(0x53a82eb794f2f?, {0x0?, 0x554289?, 0x0?})
Feb 13 21:55:18 Hub: /home/om26er/scm/scratch/connect/transport/fasthttpwebsocketpeer.go:89 +0x38
Feb 13 21:55:18 Hub: github.com/code/connect/server.(*ConnectionHandler).startAutoPinger.func1()
Feb 13 21:55:18 Hub: /home/om26er/scm/scratch/connect/server/connectionhandler.go:333 +0xd4
Feb 13 21:55:18 Hub: created by github.com/code/connect/server.(*ConnectionHandler).startAutoPinger
Feb 13 21:55:18 Hub: /home/om26er/scm/scratch/connect/server/connectionhandler.go:323 +0xac
from websocket.
Could you share your code? please
from websocket.
I just use this example https://github.com/fasthttp/websocket/tree/master/examples/chat/fasthttp
from websocket.
@savsgio @maxjust I've managed to reproduce the issue.
just run this script in a browser console several times:
for (let i = 0; i < 40000; i++) {
(new WebSocket(`ws://${document.location.host}/ws`)).onopen = () => (
conn.send('asdfasdf')
)
}
note: browser console should be opened in the context of this example page (e.g. localhost:8080)
from websocket.
I'm having the same issue. Has anyone solved this?
from websocket.
Hi @OPTIONPOOL,
Could you explain your case, please?
from websocket.
Hi @OPTIONPOOL,
Could you explain your case, please?
This is my code, and the crash's stack trace is exactly the same as the above example starting from conn.WriteMessage.
if conn != nil {
connectionMutex.Lock()
err := conn.WriteMessage(1, []byte(response))
connectionMutex.Unlock()
}
from websocket.
Which versions are you using of the websocket and fasthttp packages??
from websocket.
Which versions are you using of the websocket and fasthttp packages??
These are the packages that I am currently using.
github.com/fasthttp/websocket v1.4.1
github.com/valyala/fasthttp v1.8.0
github.com/qiangxue/fasthttp-routing v0.0.0-20160225050629-6ccdc2a18d87
from websocket.
Any progress so far?
from websocket.
I have been researching about it but I don't get to reproduce the error in my laptop.
Could you share your code and the panic stack trace, please?
from websocket.
@OPTIONPOOL, my quick solution is
if c == nil {
return errors.New("Connection already dropped")
}
at https://github.com/fasthttp/websocket/blob/master/conn.go#L752
from websocket.
Hi @om26er,
Sorry for my delayed answer!
Could you share the ping handler code, please?
Remember that websocket connections are not safe concurrent, so if you are starting a custom ping handler in a second gorutine into the upgrader you will get race conditions, so you must use this to ping connections (https://pkg.go.dev/github.com/fasthttp/websocket#Conn.SetPingHandler)
Also see: https://pkg.go.dev/github.com/fasthttp/websocket#hdr-Concurrency
from websocket.
Related Issues (20)
- Possible to support "nhooyr/websocket" then gorilla/websocket ? HOT 2
- panic: repeated read on failed websocket connection HOT 1
- Re-uploading v1.4.2 has introduced checksum mismatch HOT 1
- Beta releases HOT 3
- Type mismatch if using Fiber v2 HOT 1
- IsWebsocketUpgrade returning false HOT 3
- [BUG] - go get -u error on fetching the project HOT 15
- Replace flate with the flate pool from fasthttp HOT 2
- Case caused FastHTTPIsWebSocketUpgrade prediction false.
- panic: concurrent write to websocket connection HOT 5
- panic nil: websocket.(*Conn).beginMessage HOT 5
- Since gorilla projects are archived, how would it impact this project ? HOT 2
- Migrate from deprected `ioutil` to `io`
- Please return different error when server responds with non-101 status code HOT 1
- Is there any plan to support websocket client of fasthttp? HOT 5
- writing on closed connection without getting error !
- multiple user connection on the same goroutine?
- multiple user connection on the same goroutine?
- Library required case-sensitive "Upgrade" header HOT 1
- is it possible to obtain the file descriptor from fiber websocket?
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 websocket.