It's hard to suggest something specific without seeing what lib/message_queue/publisher.rb does and knowing
whether this can be reproduced quickly or takes hours or days in a production environment. Please elaborate.
If it happens in production then it might be the simple fact that timeouts in distributed systems are
going to happen at some point. If it happens repeatedly in a short lived development environment, the list of possible causes
would be quite different.
[1] explains a few Web server-specific threading topics but the issue can be as basic as connection loss that hasn't been detected yet [2].
Applications, and in particular publishers, should take care of reopening their connections and using publisher confirms for data safety [3][4].
See server logs for additional clues [5].