1

I am working in project with websockets and MQTT. Websocket server receives 4 messages from mqtt and I made it loop to receive any other messages. However, if there are no messages, Encoded_fixed_header = gen_tcp:recv(Socket, 0) gives an error because there are no messages to receive. I did some research on gen_tcp:recv and it says that it waits infinitely for a message, but it seems not and it closes the socket.

recieve(Socket,WsPID) ->
    Encoded_fixed_header = gen_tcp:recv(Socket, 0),
    Length = gen_tcp:recv(Socket, 0)
    Variable_Header = gen_tcp:recv(Socket, 0),
    Playload=gen_tcp:recv(Socket, 0),
    recieve(Socket,WsPID).

What could be the problem?

4

1 回答 1

0

在启动服务器时检查 gen-tcp:listen/2 中的 active 参数的值,如果使用默认值,则检查 inet_default_connect_options 中的值。

于 2014-07-02T04:20:36.027 回答