ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
898 stars 231 forks source link

notowner behaviour #175

Closed Revent closed 5 years ago

Revent commented 5 years ago

After gun:ws_upgrade any requests in the same connection are break with

{notowner,"Operations are restricted to the owner of the connection."}

how can i avoid it?

essen commented 5 years ago

If you mean you want to use multiple processes for sending frames, you probably should comment on this ticket: https://github.com/ninenines/gun/issues/58

Revent commented 5 years ago

I use one process for sending frames. Only when I do ws_upgrade I get this error.

essen commented 5 years ago

But you do this in a different process, surely? You need to provide more information.

Revent commented 5 years ago

i use one gen_server for ws and http query.

Revent commented 5 years ago

like this and when i call cast i got notowner https://gist.github.com/Revent/8649f3eb2c7e7e25da72de7eae23207d

essen commented 5 years ago

The error is incorrect, but it's expected to have an error when doing this. You can't do POST requests on a Websocket connection. Websocket takes over the whole connection and only Websocket data can be sent once the connection is upgraded.

If you need to do both you'll want two connections.

Note that HTTP/2 has recently added Websocket support but few servers support it (Cowboy does if enabled) and Gun has no support for it yet, so that's still far off.

Revent commented 5 years ago

ok, thanks.