There is a server running on 192.168.0.10 we lost power and the server had to restart, the thing is our application have a function called StartReceive() that create a Socket then call a socket.Connect(IPEndPoint). But I get this error "No connection could be made because the target machine actively refused it "192.168.0.10:2131"" I am new at this company and I am the only one, every one is on leave for the next 2 weeks. I've gathered some information but nothing seems to fit together, I feel like I am missing a piece of the puzzle.
I've read these, but nothing helped me:
- http://csharp.net-informations.com/communications/connection.htm
- No connection could be made because the target machine actively refused it?
- https://www.codeproject.com/Questions/5332894/System-net-sockets-socketexception-no-connection-c
- https://learn.microsoft.com/en-us/answers/questions/626063/no-connection-could-be-made-because-the-target-mac
At the top of my class I have this:
public static string DBAvantage = "02";
public static string PassAvantage = "PASSWORD";
List<string> lcommande = new List<string> { "LOGIN," + DBEngine.DBAvantage + ",OPERATEUR," + DBEngine.PassAvantage + "\n" };
These infos let me think that Advantage is a DB
When I the code run and it get to the function StartReceive(), it crash and I get this error "No connection could be made because the target machine actively refused it "192.168.0.10:2131""
private void StartRecieve()
{
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPAddress hostadd = IPAddress.Parse("192.168.0.10");
int port = Int32.Parse("2131");
IPEndPoint EPhost = new IPEndPoint(hostadd, port);
s.Connect(EPhost);
int cnt = 0;
string tmp = null;
Byte[] firstb = new Byte[1];
bool finish = false;
while (!finish)
{
try
{
Byte[] receive = new Byte[1];
int ret = s.Receive(receive);
if (ret > 0)
{
switch (receive[0])
{
case 11: //check start message
cnt = 0;
break;
case 10: // check end message
cnt = 0;
finish = HandleText(tmp);
tmp = null;
if (ncommande < lcommande.Count)
{
Byte[] bBuf;
string buf;
buf = String.Format(lcommande[ncommande]);
bBuf = ASCII.GetBytes(buf);
s.Send(bBuf, 0, bBuf.Length, 0);
ncommande++;
}
break;
default:
if (cnt == 0)
firstb[0] = receive[0];
tmp += Encoding.ASCII.GetString(receive);
cnt++;
break;
}
}
}
catch
{
if (!s.Connected)
{
break;
}
}
}
s.Disconnect(true);
t.Abort();
}
I tried to look on internet what is running on port 2131. I found this: Port 2131 internet search result
I've been trying to search things about the service avantageb2b, but nothing comes out on internet. This is the only informations I've found. Is it possible to restart this service ? What can I do ? My guest is the power loss made the server restart but this service didn't restart has it should have been and when I try to listen at it, it can't.