Skip to content

Commit

Permalink
Merge pull request #48 from wistia/anders/debug-socket-closed
Browse files Browse the repository at this point in the history
Close the read/recv loop if we receive {:error, "socket closed"}
  • Loading branch information
chen-anders committed Dec 21, 2023
2 parents e251bf4 + 47b0c9d commit a3e27b7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/nsq/connection/message_handling.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ defmodule NSQ.Connection.MessageHandling do
"""
def recv_nsq_messages(conn_state, conn) do
case conn_state |> Buffer.recv(4) do
# close the read loop if socket is closed
{:error, "socket closed"} ->
NSQ.Logger.error("error: socket closed - closing read loop")
conn |> C.close(conn_state)

{:error, :timeout} ->
# If publishing is quiet, we won't receive any messages in the timeout.
# This is fine. Let's just try again!
Expand Down

0 comments on commit a3e27b7

Please sign in to comment.