[rabbitmq-discuss] Error: RabbitMQ.Client.ConnectionFactory.cs - "Only one usage of each socket address (protocol/network address/port) is normally permitted"

Tony Garnock-Jones tonyg at lshift.net
Wed Sep 2 22:55:08 BST 2009


Hi Patrick,

Patrick Kenney wrote:
> So i think you are agreeing with me that [...] I am using the same
> socket over and over again, but creating new connections to it...

No, I think you are creating fresh sockets (TCP connections) each time.
Both fresh instances of .NET's "Socket" class, and fresh TCP port number
allocations.

> "Only one usage of each socket address (protocol/network
> address/port) is normally permitted" Is not a result of exhausting
> all available sockets on the system, its a result of TCP being unable
> to dispose fast enough

Close enough, yes. The message is descriptive text associated with the
socket error code EADDRINUSE (WSAEADDRINUSE on Windows), which has a few
meanings, one of which relates to the inability of the system to
allocate a fresh transient port number.

> ... so even though I have already closed the socket explicitly the
> system has not disposed of it yet, so it thinks I am trying to reuse
> the same socket... (This is confirmed using the debugger & wireshark
> (packetsniffer)...

That's right.

> Taking your suggestion to make IModel and IConnection module level, my
> threaded PublishMessage method now looks like the following...

It looks much better. Avoiding needless connection reestablishment is
generally a good idea.

> so the error is fixed, but... I still cannot even come close to the 4000
> messages per second capability (with better then twice the hardware)
> described at:
> http://www.rabbitmq.com/faq.html

You mentioned earlier that your messages are 400 kilobytes each. If you
have a 100 megabit ethernet, you will saturate your network link at
around 25 of these per second. If, as you mentioned earlier, you are
sending 4000 copies of a 400kB message, then with a 100 megabit
ethernet, you will be unlikely to see the task complete in less than
two-and-a-half minutes.

Regards,
  Tony




More information about the rabbitmq-discuss mailing list