Ошибка 10048 address already in use

I’m writing a custom TCP server and client and on doing a ton of requests (60,000 to be exact) I begin to get this socket error of 10048, which should mean «the address is already in use.»

The error keeps happening unless I pause the process for like 2 or 3 minutes and then begin it again, and then it begins to bring up the same error a short while after restarting it. If I pause the client process and restart the server process, I still get the same error on the client. So it is a complete client side problem.

This does not make sense though, this error only usually occurs when binding and this error happens on the client and not the server. What could be the possible reasons for it?

A small excerpt of my initialization:

TcpClient client = new TcpClient();
client.Connect("XXXXX -- some ip", 25000);
client.NoDelay = true;
NetworkStream clientStream = client.GetStream();

Also, everything else seems to be working fine(including the amount of time it takes to send back and forth) and this works perfectly when using 127.0.0.1 but when putting it on another LAN computer I begin to get the 10048 error.

Is there something wrong with how I initialize it? What else could cause this error on the client side?

Socket Error 10048 — Specified Address Already in Use

This error only normally occurs during VPOP3 startup. It occurs if some other software running on the same machine as VPOP3 is using one of the ports that VPOP3 is already using. This could be a proxy like WinGate, WinProxy or anti-virus software that acts as a proxy, an LDAP server (e.g. Active Directory) or another mail server program (e.g. Exchange Server). The latter two causes are particularly common on server versions of Windows.

To prevent this problem you should either remove the conflicting service from the other software or change the port which either that other software or VPOP3 uses for that mail service. You can change the ports that VPOP3 uses for its various services on the Services page in the VPOP3 settings.

There are two ways to find out which program is using the conflicting port number. Each provides different evidence so if the results of one method are unclear try the other.

Method 1

Open a command prompt and at the prompt type in telnet <ip> <port> where <ip> is the IP address of the VPOP3 machine and <port> is the port number which is in conflict.

The response you get back should indicate the name of the program currently using the port.

Method 2

The alternative is to use a free tool called TCPView (originally from SysInternals) which lists all the ports currently in use for both TCP and UDP along with which programs are using them.

думаю, что у вас просто закончились динамические порты в системе…..

ошибка (учитывая что изменение max_connection не помогает) формируется вовсе не из за mysql , а из-за невозможности винды предоставить нужное число портов.

WSAEADDRINUSE
(10048)
Address already in use.
Only one usage of each socket address (protocol/IP address/port) is normally permitted. This error occurs if an application attempts to bind a socket to an IP address/port that has already been used for an existing socket, or a socket that wasn’t closed properly, or one that is still in the process of closing. For server applications that need to bind multiple sockets to the same port number, consider using setsockopt(SO_REUSEADDR). Client applications usually need not call bind at all — connectwill choose an unused port automatically.»

что в общем случае означает —

Address already in use (Адрес уже используется).
Обычно разрешено только одно использование адреса сокета (проткол/адрес IP/порт). Эта ошибка возникает, когда приложение пытается привязаться к сокету функцией bind(), но комбинация адрес IP/порт уже используется существующим сокетом, или сокет не был корректно закрыт, или продолжается процесс закрытия сокета. Для серверных приложений, требующих привязки нескольких сокетов к одному и тому же номеру порта следует использовать setsockopt(SO_REUSEADDR). Клиентские приложения обычно не используют bind() — функция connect() автоматически выбирает неиспользуемый порт.

В вашем случае, при возрастании числа запросов к базе, когда открывается и закрывается куча подключений к базе, то оти попросту не успевают закрыться. Обратите внимание, что речь идет не о том, чтобы не забыть закрыть подключение mysql, а о том, что ресурсы для НОВОГО подключения освободятся не сразу….

Если мне память не изменяет, то есть в реестре пара параметров, которые на это влияют.

один из них — TcpTimedWaitDelay. Этот параметр определяет интервал времени, в течение которого подключение находится в состоянии ожидания, прежде чем будет закрыто. Пока подключение находится в состоянии ожидания, пара сокетов не может быть использована повторно. А согласно RFC793, данное значение должно в два раза превышать максимальное время жизни пакета.
Если учесть что в Windows XP и Microsoft Windows Server 2003 значение по умолчанию было установлено на 120 секунд, то получается что целых 2 минуты система просто ждет никому не отдавая уже освободившийся ресурс.

ищем тут

Код: Выделить всё • Развернуть
HKLMSYSTEMCurrentControLSetServicesTcpipParametersTcpTimedWaitDelay

и уменьшаем значение.
если нет, то создаем
REG_DWORD – время в секундах , с допустимыми параметрами 30-300 (в десятичной системе)

и второй параметр это MaxUserPort
находится он в

Код: Выделить всё • Развернуть
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters

имеет тип DWORD и допустимые значения от десятичных 5000 (по умолчанию) до 65534

он определяет максимальный номер порта, который используется, когда программа запрашивает у системы доступный пользовательский порт.

в итоге изначально имеем в системе всего 5000-1024 = 3976 портов, доступных для приложений, да еще и повторно использовать их можно не чаще раза в 2 минуты…

отпишитесь, плиз, помогло написанное или нет ?

p.s. если параметра нет в реестре, то это не значит что он не используется, просто его значение принимается системой по умолчанию…..

по итогам размышлений над

http://bugs.mysql.com/bug.php?id=10498

и

http://bugs.mysql.com/bug.php?id=6580

Лучше установить FreeBSD, чем потратить 20 лет на Linux’ы и выяснить какой из них хуже.

Avoiding «10048 (Address already in use.)» Errors in Webserver Stress Tool

For high traffic scenarios this message shows a problem on the workstation running Webserver Stress Tool. The IP stack can’t create additional outgoing TCP/IP connections because it runs out of available socket numbers for the IP address(es) that you have configured in Webstress.

This error occurs when your workstation cannot allocate new sockets. On Windows the default limitation is 5000 — 1024 open sockets (5000 is the default max user port setting and the first 1024 ports are reserved).

You can increase the default maximum socket value in the registry:

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters

and add or modify the MaxUserPort value.

See Also

  • Microsoft article:
    «When you try to connect from TCP ports greater than 5000 you receive the error ‘WSAENOBUFS (10055)'»
  • The Cable Guy article:
    «Windows TCP/IP Ephemeral, Reserved, and Blocked Port Behavior»

Running Exchange 2013 CU7 on Server 2012R2.

Ive been working on this project on and off for the last few months, as I am the only IT guy, and a new office construction at my company has had me running cable, moving offices, workstations, and phones.

This install of Exchange was working fine up until about a week ago. When I came back to finish its setup, I noticed that I was not able to send email internally anymore. Connecting to OWA says the message was sent, but it never arrives. After some more
investigation, it turns out the MSExchageDelivery service will not run.

Checking on this service, it indicates that it is starting/stopping, but never getting to the running stage. I have tried everything that I can think of, including uninstalling and re-installing the software. I have scoured the internet looking for solutions,
but not finding one that will take care of the problem.

Looking in the event viewer under Windows Logs -> Application I do see alot of information about MSExchangeTransportDelivery. Seems to be looping through a set of events….

1. Error MSExchangeTransportDelivery Failed to start listening (Error: 10048). Binding: 0.0.0.0:475

2. Error MSExchangeTransportDelivery This address is already in use. Binding: 0.0.0.0:475.

3. Error MSExchangeTransportDelivery Inbound direct trust authentication failed for certificate %1. The source IP address of the server that tried to authenticate to Microsfot Exchage is [%2]. Make sure EdgeSync is running properly.

4. Information MSExchangeTransportDelivery The service will be stopped. Reason TCP/IP socket error. The service will stop.

5. Information MSExchangeTransportDelivery A configuration update for Microsoft.Exchange.Transport.TransportServerConfiguration has successfully completed.

6. Information MSExchangeTransportDelivery A configuration update for Microsoft.Exchange.Data.Directory.SystemConfiguration.MailboxTransportServer has successfully completed.

7. Information MSExchangeTransportDelivery A configuration update for Microsoft.Exchange.Transport.X400AuthoritativeDomainTable has successfully completed.

8.Information MSExchangeTransportDelivery A configuration update for Microsoft.Exchange.Transport.AcceptedDomainTable has successfully completed.

9.Information MSExchangeTransportDelivery A configuration update for Microsoft.Exchange.Transport.ReceiveConnectorConfiguration has successfully completed.

10. Information MSExchangeTransportDelivery A configuration update for Microsoft.Exchange.Transport.RemoteDomainTable has successfully completed.

11.Information MSExchangeTransportDelivery A configuration update for Microsoft.Exchange.Transport.TransportSettingsConfiguration has successfully completed.

12.Information MSExchangeTransportDelivery We are doing a full mailbox database reload as part of routing tables loading due to: First read.

Not sure where to go from here… any and all help is appreciated.

Возможно, вам также будет интересно:

  • Ошибка 1004 при установке игры
  • Ошибка 1004 при печати что это
  • Ошибка 10011 easyanticheat gta 5 rp
  • Ошибка 1004 при запуске программы
  • Ошибка 10010 от источника distributedcom

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии