473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Sockets, Ports & NAT in C# -- [shaniqua:hover]

I've designed a C# application consisting of two EXEs: a client and
server. The server runs on my Win2000 Server box, and the client runs on my
customers' machines -- typically XP. The client app connects to the server,
makes a request, and awaits a response. The server sends back the response
at which point the client disconnects. The connection takes place on port
20198 (TCP). My server app was coded in such a way that only 10 simultaneous
connections are allowed from any client IP address. I did this to prevent
certain types of DOS attacks. Everything is working well -- except for one
customer.

This customer is saying that he is unable to connect to my server. The
server is rejecting his connection because his IP address has already
established 10 connections with my server. Sure enough, if I do a
"netstat -n" on my server, I see 10 connections from his IP. What makes this
interesting is that this customer does NOT have 10 connections open to my
server. I did a 'netstat' on *his* computer, the only machine in his office,
and NO such connections appeared. Even after physically turning his machine
OFF, these connections refuse to die. I can still see them via 'netstat' on
my server.

The only ways to get rid of these connections is to do ONE of the
following:

1) restart server.exe on my server.
2) reboot the customer's firewall.

Clearly, what is happening is that when my customer's client application
closes the connection, his LOCAL computer closes the connection, but his
firewall does not. It keeps it open indefinitely. I've never encountered
such bizarre behavior from a firewall.

Since the problem started yesterday, I asked my customer's I.T. person
if he made any changes to the firewall that day. He said that he HAD made a
change to his GnatBox firewall -- the change being that he added a VPN
tunnel to another branch office. However, I don't see how such a change
would be causing the odd behavior being exhibited by his firewall.

This problem only occurs with this one particular app that uses port
20198. Another almost identical app which uses port 8721 does NOT exhibit
the problem. Is there anything special about port 20198 that I should know?
When designing the app, I just chose 20198 at random. I've read that it's
best to use high-numbered ports for custom apps so as not to conflict with
the lower-numbered "well known" ports.

Any suggestions?

Shaniqua Jones
Nov 16 '05 #1
10 1623
"Shaniqua Jones" wrote in message
news:ut*************@TK2MSFTNGP10.phx.gbl...
: I've designed a C# application consisting of two EXEs: a client and
: server. The server runs on my Win2000 Server box, and the client runs on
my
: customers' machines -- typically XP. The client app connects to the
server,
: makes a request, and awaits a response. The server sends back the response
: at which point the client disconnects. The connection takes place on port
: 20198 (TCP). My server app was coded in such a way that only 10
simultaneous
: connections are allowed from any client IP address. I did this to prevent
: certain types of DOS attacks. Everything is working well -- except for one
: customer.
:
: This customer is saying that he is unable to connect to my server. The
: server is rejecting his connection because his IP address has already
: established 10 connections with my server. Sure enough, if I do a
: "netstat -n" on my server, I see 10 connections from his IP. What makes
this
: interesting is that this customer does NOT have 10 connections open to my
: server. I did a 'netstat' on *his* computer, the only machine in his
office,
: and NO such connections appeared. Even after physically turning his
machine
: OFF, these connections refuse to die. I can still see them via 'netstat'
on
: my server.
:
: The only ways to get rid of these connections is to do ONE of the
: following:
:
: 1) restart server.exe on my server.
: 2) reboot the customer's firewall.
:
: Clearly, what is happening is that when my customer's client
application
: closes the connection, his LOCAL computer closes the connection, but his
: firewall does not. It keeps it open indefinitely. I've never encountered
: such bizarre behavior from a firewall.
:
: Since the problem started yesterday, I asked my customer's I.T. person
: if he made any changes to the firewall that day. He said that he HAD made
a
: change to his GnatBox firewall -- the change being that he added a VPN
: tunnel to another branch office. However, I don't see how such a change
: would be causing the odd behavior being exhibited by his firewall.
:
: This problem only occurs with this one particular app that uses port
: 20198. Another almost identical app which uses port 8721 does NOT exhibit
: the problem. Is there anything special about port 20198 that I should
know?
: When designing the app, I just chose 20198 at random. I've read that it's
: best to use high-numbered ports for custom apps so as not to conflict with
: the lower-numbered "well known" ports.

Are you telling the client to close the connections or just hoping they will
on their own? It sounds like the proxy is keeping it open. Your app should
not depend on the remote hardware to determine when the connection should be
closed but rather notify it to terminate the connections from the server.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Online Support for IT Professionals -
http://support.microsoft.com/service...p?fr=0&sd=tech
How-to: Windows 2000 DNS:
http://support.microsoft.com/default...b;EN-US;308201
FAQ W2K/2K3 DNS:
http://support.microsoft.com/default...b;EN-US;291382
Nov 16 '05 #2
> Are you telling the client to close the connections or just hoping they
will
on their own? It sounds like the proxy is keeping it open. Your app should not depend on the remote hardware to determine when the connection should be closed but rather notify it to terminate the connections from the server.


The client app automatically closes the connection after the information
is received. No problem there.

There are many ways around this problem -- for example, I could have the
server automatically close a connection if it's been idle for too long.
Although I'm not at a loss for solutions, I'm curious as to why this symptom
would be happening at all. I'm wondering if it has something to do with the
port that I chose.

Nov 16 '05 #3
"Shaniqua Jones" <ki*******@Neverland.com> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
: > Are you telling the client to close the connections or just hoping they
: will
: > on their own? It sounds like the proxy is keeping it open. Your app
: should
: > not depend on the remote hardware to determine when the connection
should
: be
: > closed but rather notify it to terminate the connections from the
server.
:
: The client app automatically closes the connection after the
information
: is received. No problem there.

Perhaps the client should notify the server it's done so the server can
close the connection on it's end although having a timeout might still be
needed.

: There are many ways around this problem -- for example, I could have
the
: server automatically close a connection if it's been idle for too long.
: Although I'm not at a loss for solutions, I'm curious as to why this
symptom
: would be happening at all. I'm wondering if it has something to do with
the
: port that I chose.

I doubt it's the port you chose. I'm not aware of them being unique in that
respect. You can test with another port but if it was the port, wouldn't
all of them being having issues instead of just one user? Is it possible
the user can run the client from a different location that doesn't use this
device to test it? I cannot tell you why it appears to cache the
connections. I think what you might find is if this one does it, and it is
the firewall, then you might run into other devices that do the same thing
and even if you could make a modification in the firewall, this problem may
resurface.

Nov 16 '05 #4
> Perhaps the client should notify the server it's done so the server can
close the connection on it's end although having a timeout might still be
needed.
That's probably the direction I'm going to go.
I doubt it's the port you chose. I'm not aware of them being unique in that respect. You can test with another port but if it was the port, wouldn't
all of them being having issues instead of just one user?


Precisely. My thoughts exactly... That's why this is so frustrating....
:(

It bugs me that I'll probably never discover the real reason for this
error. One other thing of note. I discovered that the problem started
immediately after my customer upgraded the firmware on his GnatBox firewall.
Nov 16 '05 #5
"Shaniqua Jones" <ki*******@Neverland.com> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
: > Are you telling the client to close the connections or just hoping they
: will
: > on their own? It sounds like the proxy is keeping it open. Your app
: should
: > not depend on the remote hardware to determine when the connection
should
: be
: > closed but rather notify it to terminate the connections from the
server.
:
: The client app automatically closes the connection after the
information
: is received. No problem there.

Perhaps the client should notify the server it's done so the server can
close the connection on it's end although having a timeout might still be
needed.

: There are many ways around this problem -- for example, I could have
the
: server automatically close a connection if it's been idle for too long.
: Although I'm not at a loss for solutions, I'm curious as to why this
symptom
: would be happening at all. I'm wondering if it has something to do with
the
: port that I chose.

I doubt it's the port you chose. I'm not aware of them being unique in that
respect. You can test with another port but if it was the port, wouldn't
all of them being having issues instead of just one user? Is it possible
the user can run the client from a different location that doesn't use this
device to test it? I cannot tell you why it appears to cache the
connections. I think what you might find is if this one does it, and it is
the firewall, then you might run into other devices that do the same thing
and even if you could make a modification in the firewall, this problem may
resurface.

Nov 16 '05 #6
> Perhaps the client should notify the server it's done so the server can
close the connection on it's end although having a timeout might still be
needed.
That's probably the direction I'm going to go.
I doubt it's the port you chose. I'm not aware of them being unique in that respect. You can test with another port but if it was the port, wouldn't
all of them being having issues instead of just one user?


Precisely. My thoughts exactly... That's why this is so frustrating....
:(

It bugs me that I'll probably never discover the real reason for this
error. One other thing of note. I discovered that the problem started
immediately after my customer upgraded the firmware on his GnatBox firewall.
Nov 16 '05 #7
"Shaniqua Jones" <ki*******@Neverland.com> wrote in message
news:uC****************@TK2MSFTNGP12.phx.gbl...
: > Perhaps the client should notify the server it's done so the server can
: > close the connection on it's end although having a timeout might still
be
: > needed.
:
: That's probably the direction I'm going to go.
:
: > I doubt it's the port you chose. I'm not aware of them being unique in
: that
: > respect. You can test with another port but if it was the port,
wouldn't
: > all of them being having issues instead of just one user?
:
: Precisely. My thoughts exactly... That's why this is so
frustrating....
: :(
:
: It bugs me that I'll probably never discover the real reason for this
: error. One other thing of note. I discovered that the problem started
: immediately after my customer upgraded the firmware on his GnatBox
firewall.

I went to gta.com, I think it was, and looked at some of the docs but not
knowing which router might have been the reason I really didn't see anything
related. I didn't sign up for their discussion forums but that might be an
avenue to explore. It seems I remember someone asking about something
similar with a proxy server caching connections but I believe it was related
to issues regarding the true IP address.

How does the server close the connection now?
Nov 16 '05 #8
"Shaniqua Jones" <ki*******@Neverland.com> wrote in message
news:uC****************@TK2MSFTNGP12.phx.gbl...
: > Perhaps the client should notify the server it's done so the server can
: > close the connection on it's end although having a timeout might still
be
: > needed.
:
: That's probably the direction I'm going to go.
:
: > I doubt it's the port you chose. I'm not aware of them being unique in
: that
: > respect. You can test with another port but if it was the port,
wouldn't
: > all of them being having issues instead of just one user?
:
: Precisely. My thoughts exactly... That's why this is so
frustrating....
: :(
:
: It bugs me that I'll probably never discover the real reason for this
: error. One other thing of note. I discovered that the problem started
: immediately after my customer upgraded the firmware on his GnatBox
firewall.

I went to gta.com, I think it was, and looked at some of the docs but not
knowing which router might have been the reason I really didn't see anything
related. I didn't sign up for their discussion forums but that might be an
avenue to explore. It seems I remember someone asking about something
similar with a proxy server caching connections but I believe it was related
to issues regarding the true IP address.

How does the server close the connection now?
Nov 16 '05 #9
> How does the server close the connection now?


My customer has a support incident open with the firewall manufacturer.
We'll see if anything comes of it.

The client initiates a connection to the server. Once the connection is
established, the client sends a request. The server does some processing and
sends back a response. Once the client receives the response and processes
it, it then closes the connection. The server then detects that the
connection has ended [Socket.EndReceive() returns zero or throws] and then
calls Socket.Close() [which might be somewhat redundant since the connection
is already closed].

I've been using this technique for years and it works for many other
applications and users. It only fails for this one user and only on that
particular port. The same customer using my other apps (that use other
ports) do not have this problem.Weird!

After the client disconnects, running 'netstat' on his machine shows
that the connection is gone. Good.... but when looking at the active
connections on his firewall, the connection is still alive and refuses to
die. Two times out of five, the firewall will release the connection
correctly immediately. The other three times, it'll fail.

David
Nov 16 '05 #10
"Shaniqua Jones" <ki*******@Neverland.com> wrote in message
news:ev**************@TK2MSFTNGP10.phx.gbl...
: > How does the server close the connection now?
: >
:
: My customer has a support incident open with the firewall
manufacturer.
: We'll see if anything comes of it.
:
: The client initiates a connection to the server. Once the connection
is
: established, the client sends a request. The server does some processing
and
: sends back a response. Once the client receives the response and processes
: it, it then closes the connection. The server then detects that the
: connection has ended [Socket.EndReceive() returns zero or throws] and then
: calls Socket.Close() [which might be somewhat redundant since the
connection
: is already closed].
:
: I've been using this technique for years and it works for many other
: applications and users. It only fails for this one user and only on that
: particular port. The same customer using my other apps (that use other
: ports) do not have this problem.Weird!
:
: After the client disconnects, running 'netstat' on his machine shows
: that the connection is gone. Good.... but when looking at the active
: connections on his firewall, the connection is still alive and refuses to
: die. Two times out of five, the firewall will release the connection
: correctly immediately. The other three times, it'll fail.

Is it possible you could have the client notify the server to close the
connection rather than having the server detect the loss only? I would
still use the detection in case of an unexpected disconnect but telling the
server to close would have many benefits beyond this issue.

I wonder if the firewall has a keep-alive setting but then one would wonder
why this doesn't happen with different ports. Hopefully the manufacturer
can give you some insight on the anomaly.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Online Support for IT Professionals -
http://support.microsoft.com/service...p?fr=0&sd=tech
How-to: Windows 2000 DNS:
http://support.microsoft.com/default...b;EN-US;308201
FAQ W2K/2K3 DNS:
http://support.microsoft.com/default...b;EN-US;291382
Nov 16 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michael Rozdoba | last post by:
I've had some trouble getting IE to behave in respect of applying absolute positioning to a span on an a:hover. I can get it to work, but I don't understand why certain code causes it to fail to...
8
by: Marco | last post by:
hi I'm trying to implement a CSS dropdown menu like this http://www.alistapart.com/articles/hybrid/ on this website http://www.oratoriogroppello.com/nuovo.php The problem is the Javascript...
3
by: KimberlyM | last post by:
This has been driving me crazy. I hope someone can help. The site displays perfectly in FF but all div's do not show in IE. Please help me find the problem! Thanks! Here is my css. ...
14
by: issentia | last post by:
I'm working on this site: http://www.essenceofsoy.com/redesign/index2.html and I'm having a few problems with getting the layout exactly right. 1) When the menu items are rolled over, they...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.