Closed GuillaumeMilan closed 4 years ago
It's a bad error message. The intent is for Websocket to be restricted by default to one process, but I suppose an option could be added to remove that behavior. The ws_upgrade
should also accept the reply_to
option like the other request functions.
So it is not possible to upgrade in one process and send messages in an others process (both process are intended to send messages)?
Not yet but I guess that'll make it into 2.0. A quick and dirty way to allow it would be to remove the owner=Owner
part of this line: https://github.com/ninenines/gun/blob/master/src/gun.erl#L1037
I've added reply_to, removed the notowner entirely and propagated the reply_to to all protocols when upgrading/using CONNECT. I've also added a function to change the owner of a connection as this is still relevant for automatic shutdown and up/down messages. Closing, thanks!
When you upgrade a connection into a websocket, this upgrade is process dependent. As I don't know if this is a bug or intended I open this issue. But feel free to close it if it's the normal behavior.
Description:
I have an erlang process
A
that create the connectionC
via:gun:open
and upgrade it via the commandegun:ws_upgrade
. Then I receive thegun_upgrade
message and store the connection PID and the upgrade Reference.Then I spawn a new process
B
that receive as parameter a function executing agun:ws_send/1
on the previous obtained PID and Reference.And my process
B
receives the following message:Connection needs to be upgraded to Websocket before the gun:ws_send/1 function can be used.
I am sure it is not a synchronization probleme as I successfully send messages with the process
A
before creating the processB
.Reproduce:
I am sorry, I am developping in elixir and not in erlang so the code will be in elixir.