<p>The problem was caused by my server making too many simultaneous requests to the same node.  The computer making the requests imply ran out of ports to use.</p>

CC BY-SA 4.0
2019-01-18T12:37:51.883Z
2019-01-18T12:37:51.883Z
Thorkil Værge
<p>I use the cryptean's BitcoinLib to make RPC calls to a Bitcoin node on another computer. Seemingly at random, the connection fails and I get a System.Net.Sockets.SocketException with the error code Only one usage of each socket address (protocol/network address/port) is normally permitted. I don't know if this is due to a race condition on the port number distribution on the local machine or a bug in BitcoinLib.</p>

<p>Here is the complete stack trace</p>

<ul>
<li>2018-08-15 08:48:12.5570 Fetching transaction from Bitcoin node,
txid=3586d46be7bb1875fede4349849b89daf5ed73320979da211a54146c7bd90bfb.</li>
<li>2018-08-15 08:48:12.5831 Failed during communication with Bitcoin
node.</li>
<li>2018-08-15 08:48:12.5831 An unknown web exception occured
while trying to read the JSON response</li>
<li>2018-08-15 08:48:12.5831
System.Net.WebException: Only one usage of each socket address
(protocol/network address/port) is normally permitted Only one usage
of each socket address (protocol/network address/port) is normally
permitted ---> System.Net.Http.HttpRequestException: Only one usage
of each socket address (protocol/network address/port) is normally
permitted ---> System.Net.Sockets.SocketException: Only one usage of
each socket address (protocol/network address/port) is normally
permitted    at System.Net.Http.ConnectHelper.ConnectAsync(String
host, Int32 port, CancellationToken cancellationToken)    --- End of
inner exception stack trace ---    at
System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port,
CancellationToken cancellationToken)    at
System.Threading.Tasks.ValueTask1.get_Result()    at
System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage
request, CancellationToken cancellationToken)    at
System.Threading.Tasks.ValueTask1.get_Result()    at
System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask 1
creationTask)    at System.Threading.Tasks.ValueTask 1.get_Result()<br>
at
System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage
request, Boolean doRequestAuth, CancellationToken cancellationToken) 
at
System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage
request, Uri authUri, ICredentials credentials, Boolean
preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth,
HttpConnectionPool pool, CancellationToken cancellationToken)    at
System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken)    at
System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task1 sendTask,
HttpRequestMessage request, CancellationTokenSource cts, Boolean
disposeCts)    at System.Net.HttpWebRequest.SendRequest()    at
System.Net.HttpWebRequest.GetResponse()    --- End of inner exception
stack trace ---    at System.Net.HttpWebRequest.GetResponse()    at
BitcoinLib.RPC.Connector.RpcConnector.MakeRequest[T](RpcMethods
rpcMethod, Object[] parameters)  </li>
<li>2018-08-15 08:48:12.5831    at
BitcoinLib.RPC.Connector.RpcConnector.MakeRequest[T](RpcMethods
rpcMethod, Object[] parameters)</li>
</ul>

<full-node>
Failing communication with Bitcoin node: Only one usage of each socket address (protocol/network address/port) is normally permitted
Thorkil Værge
# Failing communication with Bitcoin node: Only one usage of each socket address (protocol/network address/port) is normally permitted

(Asked by: username_0 on 2018-08-15)

I use the cryptean's BitcoinLib to make RPC calls to a Bitcoin node on another computer. Seemingly at random, the connection fails and I get a System.Net.Sockets.SocketException with the error code Only one usage of each socket address (protocol/network address/port) is normally permitted. I don't know if this is due to a race condition on the port number distribution on the local machine or a bug in BitcoinLib.

Here is the complete stack trace

* 2018-08-15 08:48:12.5570 Fetching transaction from Bitcoin node,
  txid=3586d46be7bb1875fede4349849b89daf5ed73320979da211a54146c7bd90bfb.
* 2018-08-15 08:48:12.5831 Failed during communication with Bitcoin
  node.
* 2018-08-15 08:48:12.5831 An unknown web exception occured
  while trying to read the JSON response
* 2018-08-15 08:48:12.5831
  System.Net.WebException: Only one usage of each socket address
  (protocol/network address/port) is normally permitted Only one usage
  of each socket address (protocol/network address/port) is normally
  permitted ---> System.Net.Http.HttpRequestException: Only one usage
  of each socket address (protocol/network address/port) is normally
  permitted ---> System.Net.Sockets.SocketException: Only one usage of
  each socket address (protocol/network address/port) is normally
  permitted at System.Net.Http.ConnectHelper.ConnectAsync(String
  host, Int32 port, CancellationToken cancellationToken) --- End of
  inner exception stack trace --- at
  System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port,
  CancellationToken cancellationToken) at
  System.Threading.Tasks.ValueTask1.get\_Result() at
  System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage
  request, CancellationToken cancellationToken) at
  System.Threading.Tasks.ValueTask1.get\_Result() at
  System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask 1
  creationTask) at System.Threading.Tasks.ValueTask 1.get\_Result()  
  at
  System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage
  request, Boolean doRequestAuth, CancellationToken cancellationToken)
  at
  System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage
  request, Uri authUri, ICredentials credentials, Boolean
  preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth,
  HttpConnectionPool pool, CancellationToken cancellationToken) at
  System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request,
  CancellationToken cancellationToken) at
  System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task1 sendTask,
  HttpRequestMessage request, CancellationTokenSource cts, Boolean
  disposeCts) at System.Net.HttpWebRequest.SendRequest() at
  System.Net.HttpWebRequest.GetResponse() --- End of inner exception
  stack trace --- at System.Net.HttpWebRequest.GetResponse() at
  BitcoinLib.RPC.Connector.RpcConnector.MakeRequest[T](RpcMethods
  rpcMethod, Object[] parameters)
* 2018-08-15 08:48:12.5831 at
  BitcoinLib.RPC.Connector.RpcConnector.MakeRequest[T](RpcMethods
  rpcMethod, Object[] parameters)

**Tags:** full-node


---

## 1 answers

### Answer by username_0 on 2019-01-18. Score: 0 | Accepted answer

The problem was caused by my server making too many simultaneous requests to the same node. The computer making the requests imply ran out of ports to use.


---

