• Register
Welcome to Kodlogs Q&A, programming questions and answer website.

Most popular tags

java program python php javascript android c# r mysql spring c sql-server python-3 spring-boot eclipse arrays exception ggplot2 numpy hibernate sockets sql windows tomcat jdbc string x python-2 ios ssl 7 list html entity-framework keytool pandas facebook jquery asp net java-8 intellij-idea ssl-certificate macos matlab minecraft pip django git linux node csv security js json class tsql unity3d spring-mvc heap-memory amazon-web-services reactjs for-loop scikit-learn machine-learning unit-testing winforms glmnet webpack illegalstateexception redirect code program junit maven docker xcode ubuntu typeerror loops cmd tcp math datetime cryptography loop int import https google-chrome laravel-5 fatal-error struts java-applet pytorch runtime-error conda visual-studio apache-spark pyspark garbage-collection sql-server-2005 facebook-graph-api entity-framework-4 reporting-services anova keras indentation-error laravel android-studio jupyter-notebook tcplistener orm qt virtualenv webclient prediction visual-studio-2010 compiler-errors numpy-ndarray sudo postgresql curl vagrant aspnet reporting dataframe npm nullpointerexception javafx tensorflow jsp jpa wordpress servlet indentation mongodb firebase scanner sum github deployment socketexception certificate css util oracle recursion search syntax connection float httpwebrequest ajax dictionary database main function number file html5 inno-setup jasmine osx-mavericks firebase-cloud-messaging google-play-services xcodebuild facebook-login ruby-on-rails-3 pdfkit selenium-chromedriver selenium-webdriver makefile android-gradle-plugin android-ndk cross-domain xcode6 sql-server-2012 sybase jsp-tags data-files zoo web-development-server xss functional-dependencies mysql-error-1064 node-sass gulp-sass archlinux sass data-science spring-batch psycopg2 backpropagation texture2d async-await net-mvc-4 google-calendar pdo ruby-on-rails-4 ruby-on-rails dbmigrate wp-mail github-for-windows facebook-android-sdk jsx xcb microsoft-metro react-router spring-data-jpa softmax elastic-beanstalk google-sheets-api google-spreadsheet-api cnf minidump xuggler acumatica gitlab elasticsearch-5 elasticsearch app-transport-security ios10 ios9 cdn cloudflare wampserver plpgsql aptitude salt-stack sysv parent-child android-edittext textview visual-studio-2012 android-workmanager unique-index unity2d electron theano maven-compiler-plugin pickle assetbundle rstudio bar-chart python-tesseract tomcat6 primefaces solr easymock jvm-crash tomcat7 apache-httpclient-4 web-services woodstox discord jersey-2 prepared-statement resultset sencha-cmd sencha-touch-2 sencha-touch wkhtmltopdf powermock fips apex x509certificate ibm-bpm websphere-7 file-permissions file-io accesscontrolexception grizzly atmosphere slick2d lwjgl informetica twitter-bootstrap-3 jax-rs resteasy spring-security-kerberos spring-security kerberos long-integer mapnik git-review vpython continuation homebrew xgboost android-asynctask stack-trace user-interface jaxws-maven-plugin maven-3 maven-2 browser-notsupportedexception google-maps-api-3 google-maps visual-studio-code truststore firebase-authentication aws-organizations php-7 string-formatting cplusplus visual-studio-2015 net-core net-mvc msbuild extension-methods foreign-keys windows-services react-redux inputstream quirks-mode internet-explorer-9 internet-explorer reportingservices-2005 mips linear-regression deep-learning block-device melt reshape2 floating-point webpack-dev-server javascrip 0-lollipop android-5 statsmodels avx eclipseide javafx-2 php-not-recognized command-line phpmyadmin tinyurl classnotfoundexception atom-editor android-emulator android-sdk-tools ionic2 cordova foobar2k net-2 net-4 ole-db-provider export-to-excel openrowset windows-10 vagrantfile jvm-arguments global-variables sqlexception autopostback classformatexception eof upstart ipv4 graphviz pydot atom curses unityeditor pandoc tesseract xls oledb redux spotify cxf wamp nio stacked headless typescript hyperlink outlook jackson keystore applicationcontext pipeline iis jstl encryption perfect-square objective-c carthage xcode8 indexing standard-deviation apt xampp printer connector apple mdf kubernetes destructor gettime arithmeticexception gmail mix iphone probability ioexception heuristics milliseconds disk angular cpu modx-revolution goldsky modx prevnext javascript-dictionary stack-smashing device-monitor radio-button android-actionbaractivity android-activity android-fragments java-long unqualified-id ora-12154 javc c++ java nullpointerexception runtime-error drjava awt-eventqueue dsx math-pow ajquery nosuchelementexception appcompatactivity jsf jtextfield awt jpanel thymeleaf inputmismatchexception glassfish deque anaconda jupyter flask lvalue gradle gcc servlets netbeans jdk simulation ibm na factorial javax apache arduino boot opengl virtualbox jvm margins 2147483647 cloud plot ruby angularjs plugins processor automation crash card repository push installer pointers merge editor concatenation swift formatting debugging devices module testing color arraylist sequence nested date caching expected build response ip pdf directory algorithms release collections print figure casting url expression validation integer microsoft sorting sort read logging types replace rest 8 4 email exe excel message required text 1 variable time size dll system files table runtime static random code web map http error version 0 2 my
0 votes
7 views

Problem:

I am having this issue with my code : 

"only one usage of each socket address (protocol/network address/port) is normally permitted"

Can anyone guide me please?

by (410 points)  
edited by

1 Answer

0 votes

Possible Cause:

1. This might be due to authenticated calls, if clients suspects such calls it closes the connection.Repeated calls of such action causes to connect and close connection repeatedly.

2. The other reason is your call is http ie without https calls and you have set value keep-alive = false.

3. This also means you have used all the ports for network on your machine which is 4000 ports. For 240 seconds 5 variables

{ Protocol, Local IP, Local Port, Remote IP, Remote Port} goes into TIME_WAIT state and could not be used.

Lets say if there are 16 connections per second for 4 minutes there would be 

16*4*60=3840 connections killing the ports.

Solution to fix this:

First Solution:

The port range by max default is 5000, you can increase range of port. Lets say you can do it to 65534.

Use this key HKLM\System>CurrentControlSet>Services>Tcpip>Parameters>MaxUserPort 

Second Solution:

Second option is to reduce the time period of TIME_WAIT from 4 minutes to 20 seconds.

Use this key in this case:

HKLM>System>CurrentControlSet>Services>Tcpip>Parameters>TCPTimedWaitDelay

Third Solution:

3. Doing it trhough code if you do not want to get it done through registry is another solution.

See the code below which chooses the local end point for the

connection.

Req.ServicePoint.ConnectionBindingThroughCode

 = new BindIPEndPoint(BindIPEndPointCallback);

public static IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint,

     IPEndPoint remoteEndPoint,

     int retryCount)

{

  int port = Interlocked.Increment(ref m_LastBindPortUsed); 

  Interlocked.CompareExchange(ref m_LastBindPortUsed, 4001, 54434);

  if(remoteEndPoint.AddressFamily == AddressFamily.InterNetwork) {

 return new IPEndPoint(IPAddress.Any,port);

  }

  else {

 return new IPEndPoint(IPAddress.IPv6Any,port);

  }

}

by (1.5k points)  
...