chat

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

chat

fschmidt
Administrator
I want forum threads to behave like chat in the sense that I want them update in real time.  So I need some kind of server push.  I looked at server-sent events and websockets.  Server-sent events look much simpler and cleaner to me.  I implemented a trivial server-sent events server in a Java file and it works fine.  Do you see any issues before I go ahead with this?
Reply | Threaded
Open this post in threaded view
|

Re: chat

fffilimonov
I don't see big difference. If you will not use this connection to send data to server - server-sent events is better.
But is it ok in Java? Nginx can handle many opened connections without creating threads.
Every opened page will be connected to server.

Nginx will require additional configuration for server-sent events.
Reply | Threaded
Open this post in threaded view
|

Re: chat

fschmidt
Administrator
I don't see a need to create threads in Java either.  I will put all the connections in one object and it will do the writes, either in the thread generating the event or in a worker thread.  The writes should be fast since they are just going to Nginx.

I will go ahead an implement this.  Then you can configure Nginx.
Reply | Threaded
Open this post in threaded view
|

Re: chat

fschmidt
Administrator
done.  Test using luan/website/src/examples/sse_* .
Reply | Threaded
Open this post in threaded view
|

Re: chat

fffilimonov
can you add to responses related with sse this headers?

Content-Type: text/event-stream;
Cache-Control: no-cache;
X-Accel-Buffering: no;

And I need to remove Connection header while request is proxied to luan. I tried - it works now.
And I need to disable chunked_transfer_encoding.

Maybe it's better to make a separate route for sse?
Reply | Threaded
Open this post in threaded view
|

Re: chat

fschmidt
Administrator
fffilimonov wrote
can you add to responses related with sse this headers?

Content-Type: text/event-stream;
Cache-Control: no-cache;
X-Accel-Buffering: no;
I have the first 2.  Headers are in ServerSentEvents.java lines 72-78.  You can change this as needed.

And I need to remove Connection header while request is proxied to luan. I tried - it works now.
And I need to disable chunked_transfer_encoding.
ok

Maybe it's better to make a separate route for sse?
What does "a separate route" mean?
Reply | Threaded
Open this post in threaded view
|

Re: chat

fffilimonov
Reply | Threaded
Open this post in threaded view
|

Re: chat

fschmidt
Administrator
looks good, closing
Reply | Threaded
Open this post in threaded view
|

Re: chat

fschmidt
Administrator
released to production
Reply | Threaded
Open this post in threaded view
|

Re: chat

Lizbeth Wahl
In reply to this post by fschmidt
I really like your initiative and I'm looking forward to it coming out. Also can you create a group to talk about mod apk games? I've looked all over this forum but there doesn't seem to be a group to discuss the game. I really want to share the super cool games I played at techloky. But it seems I can't share them with people looking for games like me.