473,387 Members | 1,404 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,387 software developers and data experts.

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(threading.Thread) :
def __init__(self):
nom_function_actuelle= str(sys._getframe().f_code.co_filename)
+"___"+str(sys._getframe().f_code.co_name)
try :
threading.Thread.__init__(self)
self.log_file="timeserverlog.txt"
self.PORT=37
self.TIME1970=2208988800L
self._continue=1
self.time_shift=0
message=nom_function_actuelle+"\t "+"STARTED OK "
appel_log.write_log("info",message)
except Exception, e :
message=nom_function_actuelle+"\t "+"PB:::"+str(e)
print message
appel_log.write_log("warning",message)

def set_log_file(self, file):
nom_function_actuelle= str(sys._getframe().f_code.co_filename)
+"___"+str(sys._getframe().f_code.co_name)
if os.path.exists(file):
pass
else :
f=open(file,"w")
f.close()
self.log_file=file
print "log file ",self.log_file
self.log_file=file

def reset_log_file(self):
nom_function_actuelle= str(sys._getframe().f_code.co_filename)
+"___"+str(sys._getframe().f_code.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_actuelle= str(sys._getframe().f_code.co_filename)
+"___"+str(sys._getframe().f_code.co_name)
socket.timeout(1)
service=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
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(time.time())+"\t"+str(time.asctime())+ "\t"+str(info)+"\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_actuell e+"\t
self._continue ="+str(self._continue))
print "sortie du thread"

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

main()

Jan 16 '07 #1
2 2048
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.python:

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(threading.Thread) :
def __init__(self):
nom_function_actuelle= str(sys._getframe().f_code.co_filename)
+"___"+str(sys._getframe().f_code.co_name)
try :
threading.Thread.__init__(self)
self.log_file="timeserverlog.txt"
self.PORT=37
self.TIME1970=2208988800L
self._continue=1
self.time_shift=0
message=nom_function_actuelle+"\t "+"STARTED OK "
appel_log.write_log("info",message)

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.netcom.com wu******@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestiaria.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((socket.gethostname(), 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.python:

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_file()

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("message")

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.netcom.com wu******@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: we******@bestiaria.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
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...
0
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...
10
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...
1
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...
6
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...
3
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...
1
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...
0
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. ...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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...

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.