WebSocket and Proxying ...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

WebSocket and Proxying ...

marten
Hello,

I'm playing with WebSockets under Pharo4 and this works as expected -
when using Pharo4 alone (using the Zinc packages).

But I did not get it to work, when e.g. doing a proxying via nginx (I
did not check it with Apache).

Actually Pharo4 seems to receive some stuff, because the WebSocket of
Pharo4 stuff does not work as expected after first proxying attempts.

Has anyone experience with that ?

Marten


Reply | Threaded
Open this post in threaded view
|

Re: WebSocket and Proxying ...

Sven Van Caekenberghe-2
Marten,

> On 06 May 2015, at 10:15, [hidden email] wrote:
>
> Hello,
>
> I'm playing with WebSockets under Pharo4 and this works as expected -
> when using Pharo4 alone (using the Zinc packages).
>
> But I did not get it to work, when e.g. doing a proxying via nginx (I
> did not check it with Apache).
>
> Actually Pharo4 seems to receive some stuff, because the WebSocket of
> Pharo4 stuff does not work as expected after first proxying attempts.
>
> Has anyone experience with that ?
>
> Marten

Proxying the WebSockets protocol is not easy, nor implemented everywhere, like HTTP is. This makes sense if you think about it, a WebSocket connection is a permanent connection, which takes resources, this is not something most servers like.

So it is more difficult.

Did you see/try http://nginx.org/en/docs/http/websocket.html ?

(I did not try it)

Sven


Reply | Threaded
Open this post in threaded view
|

Re: WebSocket and Proxying ...

marten
Hmm, at least I managed, that Pharo answered every second request using
the echo example

Under Windows and nginx I added to the nginx configuration. My local
Pharo server is running under 127.0.0.1:40000:

extract from nginx.conf:

http:{

    map $http_upgrade $connection_upgrade {
        default upgrade;
    }

server {

 location /ws-echo {
   proxy_pass http://127.0.0.1:40000/ws-echo ;
   proxy_http_version 1.1;
   proxy_set_header Upgrade $http_upgrade;
   proxy_set_header Connection $connection_upgrade;
 }
 location /ws-echo-client {
   proxy_pass http://127.0.0.1:40000/ws-echo-client ;
 }

 }
}



Am 06.05.2015 um 10:20 schrieb Sven Van Caekenberghe:

> Marten,
>
>> On 06 May 2015, at 10:15, [hidden email] wrote:
>>
>> Hello,
>>
>> I'm playing with WebSockets under Pharo4 and this works as expected -
>> when using Pharo4 alone (using the Zinc packages).
>>
>> But I did not get it to work, when e.g. doing a proxying via nginx (I
>> did not check it with Apache).
>>
>> Actually Pharo4 seems to receive some stuff, because the WebSocket of
>> Pharo4 stuff does not work as expected after first proxying attempts.
>>
>> Has anyone experience with that ?
>>
>> Marten
>
> Proxying the WebSockets protocol is not easy, nor implemented everywhere, like HTTP is. This makes sense if you think about it, a WebSocket connection is a permanent connection, which takes resources, this is not something most servers like.
>
> So it is more difficult.
>
> Did you see/try http://nginx.org/en/docs/http/websocket.html ?
>
> (I did not try it)
>
> Sven
>
>


--
Marten Feldtmann

Reply | Threaded
Open this post in threaded view
|

Re: WebSocket and Proxying ...

marten
Ok, I managed to make it work somehow:

I removed the static file serving from Pharo and put the
"ws-echo-client" code to the file system and it is now handled by nginx.

Now only WebSocket stuff is done by Pharo and this seems to work without
problems.

That means: the mixture of static-stuff and websocket handling breaks
the system: browser (Firefox or Chrome or IE11) <-> nginx <-> Pharo

Not the solution I wanted, but at least a way to make WebSockets working
under Pharo ...

Marten



Am 06.05.2015 um 16:48 schrieb [hidden email]:

> Hmm, at least I managed, that Pharo answered every second request using
> the echo example
>
> Under Windows and nginx I added to the nginx configuration. My local
> Pharo server is running under 127.0.0.1:40000:
>
> extract from nginx.conf:
>
> http:{
>
>     map $http_upgrade $connection_upgrade {
>         default upgrade;
>     }
>
> server {
>
>  location /ws-echo {
>    proxy_pass http://127.0.0.1:40000/ws-echo ;
>    proxy_http_version 1.1;
>    proxy_set_header Upgrade $http_upgrade;
>    proxy_set_header Connection $connection_upgrade;
>  }
>  location /ws-echo-client {
>    proxy_pass http://127.0.0.1:40000/ws-echo-client ;
>  }
>
>  }
> }
>
>
>
> Am 06.05.2015 um 10:20 schrieb Sven Van Caekenberghe:
>> Marten,
>>
>>> On 06 May 2015, at 10:15, [hidden email] wrote:
>>>
>>> Hello,
>>>
>>> I'm playing with WebSockets under Pharo4 and this works as expected -
>>> when using Pharo4 alone (using the Zinc packages).
>>>
>>> But I did not get it to work, when e.g. doing a proxying via nginx (I
>>> did not check it with Apache).
>>>
>>> Actually Pharo4 seems to receive some stuff, because the WebSocket of
>>> Pharo4 stuff does not work as expected after first proxying attempts.
>>>
>>> Has anyone experience with that ?
>>>
>>> Marten
>>
>> Proxying the WebSockets protocol is not easy, nor implemented everywhere, like HTTP is. This makes sense if you think about it, a WebSocket connection is a permanent connection, which takes resources, this is not something most servers like.
>>
>> So it is more difficult.
>>
>> Did you see/try http://nginx.org/en/docs/http/websocket.html ?
>>
>> (I did not try it)
>>
>> Sven
>>
>>
>
>


--
Marten Feldtmann

Reply | Threaded
Open this post in threaded view
|

Re: WebSocket and Proxying ...

Sven Van Caekenberghe-2
Good that it works now, maybe your problem is that /ws-echo comes before and maybe also matches /ws-echo-client ? But I am no nginx expert.

Maybe you try serving and proxying it as /client-ws-echo ? Or switch the order ?

> On 06 May 2015, at 20:11, [hidden email] wrote:
>
> Ok, I managed to make it work somehow:
>
> I removed the static file serving from Pharo and put the
> "ws-echo-client" code to the file system and it is now handled by nginx.
>
> Now only WebSocket stuff is done by Pharo and this seems to work without
> problems.
>
> That means: the mixture of static-stuff and websocket handling breaks
> the system: browser (Firefox or Chrome or IE11) <-> nginx <-> Pharo
>
> Not the solution I wanted, but at least a way to make WebSockets working
> under Pharo ...
>
> Marten
>
>
>
> Am 06.05.2015 um 16:48 schrieb [hidden email]:
>> Hmm, at least I managed, that Pharo answered every second request using
>> the echo example
>>
>> Under Windows and nginx I added to the nginx configuration. My local
>> Pharo server is running under 127.0.0.1:40000:
>>
>> extract from nginx.conf:
>>
>> http:{
>>
>>    map $http_upgrade $connection_upgrade {
>>        default upgrade;
>>    }
>>
>> server {
>>
>> location /ws-echo {
>>   proxy_pass http://127.0.0.1:40000/ws-echo ;
>>   proxy_http_version 1.1;
>>   proxy_set_header Upgrade $http_upgrade;
>>   proxy_set_header Connection $connection_upgrade;
>> }
>> location /ws-echo-client {
>>   proxy_pass http://127.0.0.1:40000/ws-echo-client ;
>> }
>>
>> }
>> }
>>
>>
>>
>> Am 06.05.2015 um 10:20 schrieb Sven Van Caekenberghe:
>>> Marten,
>>>
>>>> On 06 May 2015, at 10:15, [hidden email] wrote:
>>>>
>>>> Hello,
>>>>
>>>> I'm playing with WebSockets under Pharo4 and this works as expected -
>>>> when using Pharo4 alone (using the Zinc packages).
>>>>
>>>> But I did not get it to work, when e.g. doing a proxying via nginx (I
>>>> did not check it with Apache).
>>>>
>>>> Actually Pharo4 seems to receive some stuff, because the WebSocket of
>>>> Pharo4 stuff does not work as expected after first proxying attempts.
>>>>
>>>> Has anyone experience with that ?
>>>>
>>>> Marten
>>>
>>> Proxying the WebSockets protocol is not easy, nor implemented everywhere, like HTTP is. This makes sense if you think about it, a WebSocket connection is a permanent connection, which takes resources, this is not something most servers like.
>>>
>>> So it is more difficult.
>>>
>>> Did you see/try http://nginx.org/en/docs/http/websocket.html ?
>>>
>>> (I did not try it)
>>>
>>> Sven
>>>
>>>
>>
>>
>
>
> --
> Marten Feldtmann
>


Reply | Threaded
Open this post in threaded view
|

Re: WebSocket and Proxying ...

marten
Good guess - but this does not help ....

Marten

Am 06.05.2015 um 21:24 schrieb Sven Van Caekenberghe:
> Good that it works now, maybe your problem is that /ws-echo comes before and maybe also matches /ws-echo-client ? But I am no nginx expert.
>
> Maybe you try serving and proxying it as /client-ws-echo ? Or switch the order ?
>



--
Marten Feldtmann