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

Joe K goodjoe2049@REDACTED
Mon Nov 12 07:54:43 CET 2018


Hi Craig!

inet:getopts(Sock, [recbuf]).

yields {ok, [{recbuf, 212992}]} and setting recbuf to 999999

inet:setopts(Sock, [{recbuf, 999999}]).
ok

inet:getopts(Sock, [recbuf]).
{ok, [{recbuf, 425984}]} % not quite 999999 ...

seems to work fine, I get the full message. Thank you so much!

But I'd still be interested in knowing if there is a way to break overflowing messages into several smaller messages with gen_udp and unix sockets.

I also say some notes about gen_sctp and SOCK_SEQPACKET in v21 release notes, so I'll try it out as well.

> On Nov 11, 2018, at 8:57 PM, Joe K <goodjoe2049@REDACTED> wrote:
> 
> Actually, the problem is not with message truncation -- gen_udp never receives the full message at all. I've tried the same janus command with netcat, and it does receive the full message, so my problem must be with gen_udp. Is there some option that I can use to make it receive beyond 1460 bytes or at least break the big messages into several, and not drop the overflow silently?
> 
>> 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