Solved

WSAECONNREFUSED Error

Posted on 2002-06-14
16
365 Views
Last Modified: 2008-02-07
my cgi application in c++ uses another application written in c++ to talk to mainframe using TCP/IP call.
When i am increasing the number of request from cgi to that application , i am getting WSAECONNREFUSED error code.
I know WSAECONNREFUSED means No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host - i.e. one with no server application running.

Can any body help me resolving this issue.How can I change my application to increase the number of request that it can handle.
Please help!!!
0
Comment
Question by:msrijna
  • 5
  • 5
  • 4
  • +2
16 Comments
 
LVL 4

Expert Comment

by:pellep
ID: 7080216
Providing you know how many concurrent connections your mainfram app can handle, you can create a connection -pool on the client side (with as many connections as possible). When requests are made, they try to grab a connection from the pool, and wait if no connection is available. It will allow your client to handle more request, but at a lower pace.
0
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 7080350
This is a SERVER problem and cannot be fixed on your application.  All you really can do is work around it.

What you should do, if this is caused by a server being too busy, is to setup a retry scheme and queue and have your application retry the connection so that it can eventually make a connection.

If you have any control of the server code, you might look there and see WHY it's refusing your connection.  I could be that the server is overloaded, the listening socket has too small a backlog setting.
0
 
LVL 32

Expert Comment

by:jhance
ID: 7080381
Another thought...

Is there any way to continue to use ONE connection to the server instead of continuing to open new sockets?
0
 

Author Comment

by:msrijna
ID: 7080575
server is not refusing any connection.My application which is running on the server and which is used for making tcp/ip connection to mainframe is refusing connection to cgi call.
0
 
LVL 32

Expert Comment

by:jhance
ID: 7080577
cgi calls don't get connected to.  I think you are confused.

You said, and I quote:

"talk to mainframe using TCP/IP call."

Mainframe = SERVER

SERVER is the problem as it is REFUSING your connection request.

Fix the problem on the server or do something DIFFERENT on your CLIENT to eliminate the problem.

You cannot FORCE the server to accept your incoming connection and the WSAECONNREFUSED error message is what happens when the SERVER refuses to talk to your client.

Got it?
0
 

Author Comment

by:msrijna
ID: 7080851
Oh I am sorry I confused you guys.
Here is the architecture :

CGI SERVER ----> Monitor Server-----> Mainframe

Now CGI server makes a cgi call to monitor which is a application running on a different  server and cgi call is made on a particular port and monitor application( written in c++)  sends the same request to Mainframe.
Now as and when I am increasing the number of CGI calls to Monitor , monitor is refusing connection to CGI calls  on that port.
It is returning the error code of WSAECONNREFUSED.
I would like to tell you that i am using WINSOCk 1.1 version in the monitor applicaiton for listening to CGI calls which might be the bottleeneck
0
 
LVL 4

Expert Comment

by:pellep
ID: 7080857
when you invoke listen() passing the server socket, you also specify the size of the backlog (ie maximum number of pending connections between accept() calls). Try increasing the backlog size. It might not be the best sollution if you're anticipating a constant high load, but it will take care of peak-loads.
0
 

Author Comment

by:msrijna
ID: 7080858
I am using winsock 1.1 and in case of winsock 1.1 the maximum number of backlog could be 5 .
When i am increaisng the number of requests, backlog is exceeding 5 and hense resfusing connection.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 4

Expert Comment

by:pellep
ID: 7081185
Have you considered multi-threading your server app. That way, one thread can exclusively accept connections and spawn threads to do the work wih the connected sockets.
0
 
LVL 32

Expert Comment

by:jhance
ID: 7081505
If you are using WINSOCK 1.1, that implies to me that you have Windows 95 or Windows 98 on your monitor "server".  Right?  If so, neither of these platforms is suitable for this type of application.

Get a different platform to run your monitor application that is not limited to WINSOCK 1.1 and it's 5 connection backlog.

If your hands are tied here, you'll need to re-architect.  Win95/98 are intentionally limited (i.e. crippled) to prevent you from using a backlog of more than 5.

If this is really a server platform (i.e. NT4 Server, W2K Server) then use the WINSOCK 2 interface and get rid of this WINSOCK 1.1 backlog limitation.
0
 

Author Comment

by:msrijna
ID: 7081718
I am using windows 2000 and winsock1.1.
Is there any other way otherthan upgrading winsock2.0
0
 
LVL 4

Expert Comment

by:pellep
ID: 7082013
multithreading.
0
 
LVL 32

Expert Comment

by:jhance
ID: 7082022
I fail to see how multithreaded can help here.  It's a SERVER issue!!!

I'm still totally confused about your arrangement and am frustrated by your lack of information being provided.

Windows 2000???  What Windows 2000, Pro or Server or Adv. Server?  Where is Windows 2000 running, on your client, on the "monitor server", on the mainframe, all of the above what?

It's really hard to give useful and helpful advice with so little to go on.

What also are you using WINSOCK 1.1 on W2K?  Any version of W2K has WINSOCK 2 by default! But again, the CLIENT is not the issue.  Again to re-iterate, the SERVER (in your case the monitor server) is where the problem in your situation is coming up.  You CANNOT force the server to accept more incoming connections from your client than the SERVER permits.

To again review your options:

1) FIX the SERVER to accept more than 5 incoming connections.

2) FIX the ARCHITECTURE so that greater load on the system does not require more socket connections between the client and the server.

Frankly, I think you'd do well to explore #2.  If you have any hopes in the future of scaling this to a larger system it will very quickly break down.  Gosh, you're already hitting limits with 5 connections.  What's going to happen with 500 or 5000 or even more??

A socket connection is a fairly expensive thing in terms of resources and performance.  In general it is NOT a good architecture to have a 1:1 relationship between your users and your socket connections to the server.

Why can't you design this to have the client open ONE SINGLE socket connection to the monitor server and have ALL the communications go through that single socket?  I think you'll find that the overhead is greatly reduced and the performance is greatly improved.
0
 

Author Comment

by:msrijna
ID: 7082227
I am so sorry for not provoding the enough details .I will try to put whole architecture in following lines:

CGI Server
 configuration: windows 2000 advansed server
web server : IIS 5.0
CGI application written in c++


Monitor server :
 configuration: windows 2000 advansed server
Monitor applicaiton written in c++ MFC which receives request from CGI application using TCP/IP.This monotor application runs continuosly on monitor server and receives request from CGI appication runing on different CGI server.Monitor application receives all the calls from CGI application on a particular port specified.

CGI server---CGI call---> Monitor application running on monitor server  receives the CGI call using TCP/IP and cals mainframe.


Now problem is in the frist step where CGI application is making call to Monitor application running on monitor server.When I increase the number of calls to monior application, Monitor application continues to accpet calls from CGI application but at particular limit it refuses connection to CGI application and returns error code of WSAECONNREFUSED.
Monitor application uses winsock 1.1 for listening to the specified port where CGI application sends all the calls.

So I dont think that there is any problemm in the server as server is not listening to CGI application but a application( Monitor application which is running on the Server ) is listening to all teh calls of CGI applicaiton on pre specified port.
Please let me know if I have explained the situation .
Please help me .








0
 
LVL 11

Expert Comment

by:griessh
ID: 7353299
Dear msrijna

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "jhance"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7419705
Force accepted

** Mindphaser - Community Support Moderator **
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now