473,544 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

connection to server not accepted (but no error) only after several hours

seb
Hi, this simple server (time protocol) does not respond after a few
hours, even when it is restarted. The behaviour looks to me like a
firewall blocking but I have desabled the firewall.
Using Netstat - a I find the server listed when it is running and not
listed when I stop it.
The server starts whith no error. But after about 6-8 hours there is no
way to make it respond again (even when it is restarted).

Once it is blocked, I killes it, wait for about 15 minutes without
running the server and then started again but this gives me the same
behaviour (no response).

The solution at this time is to reboot windows !!!

I have also tried to run it twice in order to get the exception that
the port is already used and an exeption is raised.
I have tried from another computer to connect to mine but it does not
manage.
When I change the port in the server it responds immediatly.

I am running winXP SP2, python 2.4.

Do you have any clues ?
Thanks in advance.
Seb.

PS : I am calling this server from another program and make it run in a
thread.
Below is the standalone version (wich is adpated from effbot site).

import socket
import struct, time
import threading
import os
import appel_log2 as appel_log
import sys
class TimeServer(thre ading.Thread) :
def __init__(self):
nom_function_ac tuelle= str(sys._getfra me().f_code.co_ filename)
+"___"+str(sys. _getframe().f_c ode.co_name)
try :
threading.Threa d.__init__(self )
self.log_file=" timeserverlog.t xt"
self.PORT=37
self.TIME1970=2 208988800L
self._continue= 1
self.time_shift =0
message=nom_fun ction_actuelle+ "\t "+"STARTED OK "
appel_log.write _log("info",mes sage)
except Exception, e :
message=nom_fun ction_actuelle+ "\t "+"PB:::"+str(e )
print message
appel_log.write _log("warning", message)

def set_log_file(se lf, file):
nom_function_ac tuelle= str(sys._getfra me().f_code.co_ filename)
+"___"+str(sys. _getframe().f_c ode.co_name)
if os.path.exists( file):
pass
else :
f=open(file,"w" )
f.close()
self.log_file=f ile
print "log file ",self.log_ file
self.log_file=f ile

def reset_log_file( self):
nom_function_ac tuelle= str(sys._getfra me().f_code.co_ filename)
+"___"+str(sys. _getframe().f_c ode.co_name)
print "resetting log file "
if os.path.exists( self.log_file):
f=open(self.log _file,"w")
f.close()

def set_time_shift( self,time_shift ):
self.time_shift =time_shift

def run(self):
nom_function_ac tuelle= str(sys._getfra me().f_code.co_ filename)
+"___"+str(sys. _getframe().f_c ode.co_name)
socket.timeout( 1)
service=socket. socket(socket.A F_INET, socket.SOCK_STR EAM)
service.bind((" ", self.PORT))
service.listen( 1)
print "listening on port", self.PORT
while self._continue= =1 :
channel, info = service.accept( )
print "connection from", info
message=str(tim e.time())+"\t"+ str(time.asctim e())+"\t"+str(i nfo)+"\n"
g=open(self.log _file,"a")
g.write(message )
g.close()
t = int(time.time() ) + self.TIME1970 + self.time_shift
t = struct.pack("!I ", t)
channel.send(t) # send timestamp
channel.close() # disco
m=nom_function_ actuelle+" response OK "+str(info)
appel_log.write _log("info",m)
#print "apres m "
print "time server self_continue=0 "
appel_log.write _log("warning", nom_function_ac tuelle+"\t
self._continue ="+str(self._co ntinue))
print "sortie du thread"

def main() :
a=TimeServer()
a.start()
a.set_log_file( "log_nw.txt ")
a.reset_log_fil e()
while 1==1 :
time.sleep(10)
#a._continue=0
pass
time.sleep(2)

main()

Jan 16 '07 #1
2 2055
seb
Hi Dennis,

I am using indeed using python logging in the appel_log2 module.
But I wanted to keep it extremly simple while accepting connection from
different processes or thread.

Regarding my main problem, I did some more testing :

1) I have enabled one time server that can be run as a service (R C C
time server) and this service is responding correctly, when at the same
time (before I kill it ) the python time server is not responding.

2) I have also tried two python time server downloaded from effbot
site. Both are not responding after the "non response from the time
server I rn" even for the first interrogation once they are started.
(Of course I have killed my time server when I run a new one).
Same behaviour no response given but no error neither.

3)
If I try to start the R c c time server when the python time server is
running there is an error (from the rcc service)
The python time server program is really bound to port 37.

if we look at the previous tests :

4)
The same python program runned on port 38 aftter the blocking is
working properly from the start.

5)
There is no exception on the python time server whether it is
responding or not.

--------------------------
partial conclusion
-------------------------

It is only python programs that are listening from the port 37 that are
blocked at a certain time.
How is it possible (without firewall enabled) ?

Thanks .
Sebastien.
Dennis Lee Bieber a écrit :
On 16 Jan 2007 07:39:35 -0800, "seb" <se************ @laposte.net>
declaimed the following in comp.lang.pytho n:

Once it is blocked, I killes it, wait for about 15 minutes without
running the server and then started again but this gives me the same
behaviour (no response).
Can't help with the lock-up problem... but...

import socket
import struct, time
import threading
import os
import appel_log2 as appel_log
import sys
class TimeServer(thre ading.Thread) :
def __init__(self):
nom_function_ac tuelle= str(sys._getfra me().f_code.co_ filename)
+"___"+str(sys. _getframe().f_c ode.co_name)
try :
threading.Threa d.__init__(self )
self.log_file=" timeserverlog.t xt"
self.PORT=37
self.TIME1970=2 208988800L
self._continue= 1
self.time_shift =0
message=nom_fun ction_actuelle+ "\t "+"STARTED OK "
appel_log.write _log("info",mes sage)

Have you considered using Python's logging module?
while 1==1 :

Redundant test...

In all historical versions of Python

while 1:

sufficed, and newer versions have

while True:
--
Wulfraed Dennis Lee Bieber KD6MOG
wl*****@ix.netc om.com wu******@bestia ria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestia ria.com)
HTTP://www.bestiaria.com/
Jan 17 '07 #2
seb
Hi Dennis,

I think I have some new informations.
My system is "blocked" now but the following change make it work again
!!!
I will test it for tonight to be sure of the improvements.

I changed :
service.bind((" ", self.PORT))
to
service.bind((s ocket.gethostna me(), self.PORT))

The strange thing is that using the "" it works for a few hours.

Regards.
Sebastien.
Dennis Lee Bieber a écrit :
On 17 Jan 2007 00:08:52 -0800, "seb" <se************ @laposte.net>
declaimed the following in comp.lang.pytho n:

1) I have enabled one time server that can be run as a service (R C C
time server) and this service is responding correctly, when at the same
time (before I kill it ) the python time server is not responding.

What behavior do you see if you don't run them as background
services, but rather from a regular console login?
2) I have also tried two python time server downloaded from effbot
site. Both are not responding after the "non response from the time
server I rn" even for the first interrogation once they are started.
(Of course I have killed my time server when I run a new one).
Same behaviour no response given but no error neither.
If you've now got a total of three programs that are not reporting
error conditions, I'd suspect there is something else wrong in the
system...
It is only python programs that are listening from the port 37 that are
blocked at a certain time.
How is it possible (without firewall enabled) ?
What response do you get from the clients attempting to connect to
this server? (I'd expect a either a flat out "denied" or, for a
stealthed firewall, a timeout with no response).
You also have a race condition in your log-file...
a.start()
a.set_log_file( "log_nw.txt ")
a.reset_log_fil e()

It is possible that the thread gets a few connections between the
.start() and the .set_log_file() and logs them to the default file name.
Also, it is possible for connections to be logged between the
.set_log_file() and the .reset_log_file () (where you wipe out the
contents of the log file).

I'd suggest putting the .start() call third in that list. That way
you create the thread object, but it is not running. Change the log file
name, wipe out any old contents, and THEN start the thread running.

My only other comment would be to add a few wolf-fences... Print
statements (if running in a console), or more logging messages (you
might want to make a method out of that internal logging so all you code
is, say

self.slog("mess age")

and "slog" does that time stamping, and file open/close...

By logging each main step (accept, send, close) you might find where
it stops.
--
Wulfraed Dennis Lee Bieber KD6MOG
wl*****@ix.netc om.com wu******@bestia ria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestia ria.com)
HTTP://www.bestiaria.com/
Jan 18 '07 #3

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

Similar topics

13
2002
by: Fortepianissimo | last post by:
Here is the situation: I want my server started up upon connection. When the first connection comes in, the server is not running. The client realizes the fact, and then starts up the server and tries to connect again. This of course all happens on the same machine (local connection only). The connections can come in as fast as 30+/sec, so...
0
5359
by: Bob | last post by:
I have an ASP.NET web application that has been running without any problems for a while. I recently transferred the site to shared hosting and had multiple users start to use the site. The problem I'm experiencing is that when many users are hitting the site at once, occasionaly I will see errors. The 3 most common ones are: "The SqlCommand is...
10
4212
by: B Moor | last post by:
Host PC: Win SBS 2003 with 2.6 GHz processor and 1GB RAM SQL Server 2000 sp3 (or latest).MS Office 2k3 I have the access 2k3 front end running on server (this may get changed) and all was well until an upgrade 1 week ago when I installed a new version of the mde (with very minor changes) and a new VB application via a VB6 installer...
1
3088
by: B Moor | last post by:
Hello, I am quite bogged down with this problem and would like some tips/help if any one has any. Thanks in advance. The Problem ----------- This system initially seemed quite stable for a few weeks but now,
6
4476
by: karim | last post by:
I have an asp.net page that stopped running properly giving the error below. The app uses a SQL Server 2000 on another server. Enterprise Manager and Query analyzer on the web server can connect to that sql server just fine and run queries. I rebooted the web server and made aspnet member of the admin group. I don't know why the error...
3
10279
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database I use System.Data.Common.DBConnection and .DBCommand. How can I keep aware from connection losses (network not availeable, db-server not...
1
5105
by: sherifbk | last post by:
Problem description ============== - I have 4 clients and 1 server (SQL server) - 3 clients are Monitoring console 1 client is operation console - Monitoring console collects some data from the control unit and store them into the Sql server - The operation console then retrieve this data from the sql for reporting and statistics...
0
5865
by: kuguy | last post by:
Hi all, I'm new to the forums, so I hope this isn't in the wrong place... I have that "Software caused connection abort: socket write error" exception error that i've never meet before. Basically what im trying to do is the following: - a client connect to a server using sslsocket. - server receive the connection and reply with the...
0
5092
by: Xionbox | last post by:
Hello everybody, The error I have seems very easy to solve, but for some odd reason I can't seem to solve it. Anyways, here's my "setup". I created a server running on localhost:1200 (telnet localhost 1200 proves that it is up and running) and I coded a client which is supposed to connect to that server and send it data. The odd part is...
0
7438
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7632
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7392
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7720
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4930
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
996
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.