ostinelli / misultin

Misultin (pronounced mee-sool-téen) is an Erlang library for building fast lightweight HTTP(S) servers, which also supports websockets.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handling streaming connection from inside a gen_server

francois2metz opened this issue · comments

Hi,

We are trying to move from yaws to misultin on U.C.Engine (https://github.com/AF83/ucengine).

We have a streaming API (aka EventSource or Server-Sent Events). The current logic is currently inside a gen_server. It makes easier to handle all cases and the connection close (https://github.com/AF83/ucengine/blob/487cef0a3ccdbfae369938ec3ec36d296ac6c686/ucengine/src/controllers/async/uce_async_stream.erl)

With misultin I don't know how to achieve the same result. The request Pid is trashed as soon as the gen_server is started. Therefore the connection is closed.

Do you have something similar to streamcontent_from_pid from yaws?

i don't know who is calling wait/11, but when this function exits you are exiting the original request pid, so misultin believes you are done with it and starts listening for a new request on the same connection.

i'm not sure why you are implementing this as a gen_server, it looks pretty simple and you might want to consider a simple refactoring towards a normal process loop, allowing the function not to exit and thus keeping the connection open.

i don't know how your overall architecture is, though, so you'll obviosuly the judge of that :)

r.