Closed mattn closed 9 months ago
Not an issue with the library, you're probably failing the origin check. There's a method to override that to allow connections from specific origins.
But some methods works fine.
I added Access-Control-Allow-Origin header but, SetClientConnectedCallback is never called.
There's a different callback to check a client's connection before it's allowed. By default it checks that the Origin header matches the Host. This is for safety as otherwise there are no checks to prevent someone from connecting to your server from unauthorized origins.
Deno/nak likely don't include an Origin header.
https://github.com/Matheus28/ws28/blob/32b51da3edb193308a30a05d3ecd61ad723863c2/src/Server.h#L70-L73
Ah, make sense. It works safety by default. Thanks.
Hmm, it have alleviated some of this, but I still get the same error sometimes. I don't think it's a problem with cloudflare relaying it, as I don't get this error on servers implemented in the Go language.
You’ll have to provide an screenshot of the exact error and the http request made to establish the connection. I haven’t experienced any of those issues, but I don’t use cloudflare to proxy websocket requests (it’s fairly expensive last I checked).
Implementation of this server
Can you show the network tab of chrome and the details there?
My recommendation would be: if you don’t need the specific feature I made this library for (insecure and secure sockets on the same port), uWS is a better library.
sure!
Do you mean https://github.com/uNetworking/uWebSockets ?
Thanks, I'll try it.
Are you sending the messages as text or as binary? Is the connection even being established? Are you sure there aren’t any errors elsewhere in your code?
To be honest I don’t reallly have the time to debug this issue for you. I use this library mostly for my own projects and I haven’t encountered anything like this.
-- Matheus Valadares
On Mon, Jan 22, 2024 at 22:03 mattn @.***> wrote:
sure!
image.png (view on web) https://github.com/Matheus28/ws28/assets/10111/ce491b5b-40b3-437b-9859-8075e2e8c7d7
image.png (view on web) https://github.com/Matheus28/ws28/assets/10111/321285d2-ae26-4fa0-a843-7f999f7dedf5
image.png (view on web) https://github.com/Matheus28/ws28/assets/10111/c826632a-0cf6-4b91-a013-cebaa2db8555
— Reply to this email directly, view it on GitHub https://github.com/Matheus28/ws28/issues/17#issuecomment-1905346798, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEWEN7J5ND7EJXDLVXK64DYP5HC7AVCNFSM6AAAAABCGIROOOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBVGM2DMNZZHA . You are receiving this because you modified the open/close state.Message ID: @.***>
Are you sending the messages as text or as binary?
alway send text
Is the connection even being established?
It should be but I don't make sure of behaviour of browsers.
Are you sure there aren’t any errors elsewhere in your code?
May be, but new WebSocket(...)
does not reach my code, I guess.
To be honest I don’t reallly have the time to debug this issue for you. I use this library mostly for my own projects and I haven’t encountered anything like this.
Right. I'll try uWS. Thanks.
After I digged my codes for while, I figure out my mistake. I sent message as binary. Sorry much.
I'm trying to implement Nostr relay server using ws28. When I connect the server implemented with ws28,
always throw exception without any messages.