[erlang-questions] Getting the whole message with unix sockets

Joe K goodjoe2049@REDACTED
Sun Nov 11 23:00:27 CET 2018


As it should, since the sock is not SOCK_STREAM. Is there a way to use SOCK_SEQPACKET via gen_sctp maybe?

> On Nov 11, 2018, at 9:01 PM, Joe K <goodjoe2049@REDACTED> wrote:
> 
> Tried using gen_tcp with SOCK_SEQPACKET and it responded with eprototype.
> 
> 1> gen_tcp:connect({local, <<"/home/vagrant/janus.sock">>}, 0, [local, binary, {ip, {local, <<"/home/vagrant/erl.sock">>}}]).
> {error,eprototype}
> 
>> On Nov 11, 2018, at 8:13 PM, Joe K <goodjoe2049@REDACTED> wrote:
>> 
>> So I've been able to start a conversation with Janus Gateway via a unix socket (see http://erlang.org/pipermail/erlang-questions/2018-November/096623.html), but now I'm a bit stuck with big messages getting truncated.
>> 
>> Example:
>> 
>> ```
>> 1> {ok, Sock} = gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/erl.sock">>}}]).
>> {ok,#Port<0.6>}
>> 
>> 2> gen_udp:send(Sock, {local, <<"/home/vagrant/janus.sock">>}, 0, <<"{\"transaction\":\"123\",\"janus\":\"info\"}">>).
>> ok
>> 
>> 3> flush().
>> Shell got {udp,#Port<0.6>,
>>              {local,<<"/home/vagrant/janus.sock">>},
>>              0,
>>              <<"{\"janus\":\"server_info\",\"transaction\":\"123\",\"name\":\"Janus WebRTC Server\",\"version\":50,\"version_string\":\"0.5.0\",\"author\":\"Meetecho s.r.l.\",\"commit-hash\":\"6b916658a88e29a0991007f6f79b6961ee02c784\",\"compile-time\":\"Sat Nov 10 13:12:23 UTC 2018\",\"log-to-stdout\":true,\"log-to-file\":false,\"data_channels\":false,\"session-timeout\":60,\"reclaim-session-timeout\":0,\"candidates-timeout\":45,\"server-name\":\"MyJanusInstance\",\"local-ip\":\"10.0.2.15\",\"ipv6\":false,\"ice-lite\":false,\"ice-tcp\":false,\"full-trickle\":false,\"rfc-4588\":false,\"static-event-loops\":0,\"api_secret\":false,\"auth_token\":false,\"event_handlers\":false,\"transports\":{\"janus.transport.http\":{\"name\":\"JANUS REST (HTTP/HTTPS) transport plugin\",\"author\":\"Meetecho s.r.l.\",\"description\":\"This transport plugin adds REST (HTTP/HTTPS) support to the Janus API via libmicrohttpd.\",\"version_string\":\"0.0.2\",\"version\":2},\"janus.transport.pfunix\":{\"name\":\"JANUS Unix Sockets transport plugin\",\"author\":\"Meetecho s.r.l.\",\"description\":\"This transport plugin adds Unix Sockets support to the Janus API.\",\"version_string\":\"0.0.1\",\"version\":1}},\"events\":{},\"plugins\":{\"janus.plugin.audiobridge\":{\"name\":\"JANUS AudioBridge plugin\",\"author\":\"Meetecho s.r.l.\",\"description\":\"This is a plugin implementing an audio conference bridge for Janus, mixing Opus streams.\",\"version_string\":\"0.0.10\",\"version\":10},\"janus.plugin.echotest\":{\"name\":\"JANUS EchoTest plugin\",\"author\":\"Meetecho s.r.l.\",\"description\":\"This is a trivial EchoTest pl">>}
>> ok
>> ```
>> 
>> So the json message is incomplete, is there a way to make `gen_udp` wait for a line break like `{packet, line}` or `{line_delimeter, Char}`?
>> 
>> Janus is using SOCK_DGRAM in the current setup, but I can also make it use SOCK_SEQPACKET and try gen_tcp (I guess), would it help? I guess, I'll have to find that out!
> 




More information about the erlang-questions mailing list