connect to existing unix socket

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

connect to existing unix socket

Joe K
tl;dr

How can I avoid:

```
1> gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/janus.sock">>}}]).
{error,eaddrinuse}
```

---

I have a janus gateway (https://github.com/meetecho/janus-gateway) running on the same host as my Erlang app and I want to be able to make them talk via a unix socket. Janus creates a SOCK_SEQPACKET or SOCK_DGRAM unix socket on startup and I want to be able to connect to it from Erlang. The problem is, when I set Janus to use SOCK_DGRAM, I can't then open it from Erlang:

```
1> gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/janus.sock">>}}]).
{error,eaddrinuse}
```

and if I set Janus to use SOCK_SEQPACKET, gen_tcp fails for me as well:

```
2> gen_tcp:connect({local, <<"/home/vagrant/janus.sock">>}, 0, [local]).
{error,eprototype}
```

What am I doing wrong?
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: connect to existing unix socket

Joe K
Sorry for my manners, forgot to say hi!

> On Nov 11, 2018, at 4:43 PM, Joe K <[hidden email]> wrote:
>
> tl;dr
>
> How can I avoid:
>
> ```
> 1> gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/janus.sock">>}}]).
> {error,eaddrinuse}
> ```
>
> ---
>
> I have a janus gateway (https://github.com/meetecho/janus-gateway) running on the same host as my Erlang app and I want to be able to make them talk via a unix socket. Janus creates a SOCK_SEQPACKET or SOCK_DGRAM unix socket on startup and I want to be able to connect to it from Erlang. The problem is, when I set Janus to use SOCK_DGRAM, I can't then open it from Erlang:
>
> ```
> 1> gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/janus.sock">>}}]).
> {error,eaddrinuse}
> ```
>
> and if I set Janus to use SOCK_SEQPACKET, gen_tcp fails for me as well:
>
> ```
> 2> gen_tcp:connect({local, <<"/home/vagrant/janus.sock">>}, 0, [local]).
> {error,eprototype}
> ```
>
> What am I doing wrong?

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: connect to existing unix socket

Joe K
In reply to this post by Joe K
If I start Janus with SOCK_DGRAM and use the following from Erlang

1> {ok, Sock} = gen_udp:open(0, [local]).
{ok,#Port<0.6>}
2> gen_udp:send(Sock, {local, <<"/home/vagrant/janus.sock">>}, 0, "{}").
ok
then I see 

Unix Sockets thread started
[WARN] Dropping packet from unknown source (no path provided)
in Janus logs.

On Nov 11, 2018, at 4:43 PM, Joe K <[hidden email]> wrote:

tl;dr

How can I avoid:

```
1> gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/janus.sock">>}}]).
{error,eaddrinuse}
```

---

I have a janus gateway (https://github.com/meetecho/janus-gateway) running on the same host as my Erlang app and I want to be able to make them talk via a unix socket. Janus creates a SOCK_SEQPACKET or SOCK_DGRAM unix socket on startup and I want to be able to connect to it from Erlang. The problem is, when I set Janus to use SOCK_DGRAM, I can't then open it from Erlang:

```
1> gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/janus.sock">>}}]).
{error,eaddrinuse}
```

and if I set Janus to use SOCK_SEQPACKET, gen_tcp fails for me as well:

```
2> gen_tcp:connect({local, <<"/home/vagrant/janus.sock">>}, 0, [local]).
{error,eprototype}
```

What am I doing wrong?


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: connect to existing unix socket

Joe K
Silly me, I should've just opened the socket with a different path.

```
{ok, Sock} = gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/erl.sock">>}}]).
gen_udp:send(Sock2, {local, <<"/home/vagrant/janus.sock">>}, 0, <<"{}">>).
```

worked fine -- Janus is happy.

On Nov 11, 2018, at 5:01 PM, Joe K <[hidden email]> wrote:

If I start Janus with SOCK_DGRAM and use the following from Erlang

1> {ok, Sock} = gen_udp:open(0, [local]).
{ok,#Port<0.6>}
2> gen_udp:send(Sock, {local, <<"/home/vagrant/janus.sock">>}, 0, "{}").
ok
then I see 

Unix Sockets thread started
[WARN] Dropping packet from unknown source (no path provided)
in Janus logs.

On Nov 11, 2018, at 4:43 PM, Joe K <[hidden email]> wrote:

tl;dr

How can I avoid:

```
1> gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/janus.sock">>}}]).
{error,eaddrinuse}
```

---

I have a janus gateway (https://github.com/meetecho/janus-gateway) running on the same host as my Erlang app and I want to be able to make them talk via a unix socket. Janus creates a SOCK_SEQPACKET or SOCK_DGRAM unix socket on startup and I want to be able to connect to it from Erlang. The problem is, when I set Janus to use SOCK_DGRAM, I can't then open it from Erlang:

```
1> gen_udp:open(0, [binary, {ip, {local, <<"/home/vagrant/janus.sock">>}}]).
{error,eaddrinuse}
```

and if I set Janus to use SOCK_SEQPACKET, gen_tcp fails for me as well:

```
2> gen_tcp:connect({local, <<"/home/vagrant/janus.sock">>}, 0, [local]).
{error,eprototype}
```

What am I doing wrong?



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions