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?