(Pyboard && CC3000) Server stops responding after a while

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Torsten
Posts: 2
Joined: Fri Jan 30, 2015 4:53 pm

(Pyboard && CC3000) Server stops responding after a while

Post by Torsten » Mon Feb 02, 2015 9:38 am

Hey there,
I've wrote a litte http server just for testing and after a while it simply stops responding. Could someone look over my code and point me in the right direction? Maybe it has something to do with memory ect... how do I debug this? Thanks.

Init CC3000 module

Code: Select all

p1 = pyb.Pin('X5')
p2 = pyb.Pin('X4')
p3 = pyb.Pin('X3')

wlan = ""
print( "initializing interface..." )
try:
	wlan = network.CC3K(pyb.SPI(1), p1, p2, p3)
	wlan.connect("my wlan","my password")
except:
	print( "Could not initialize CC3000 module. Try hard reset.")
	sys.exit(0)

print( "connecting..." )

while not wlan.isconnected():
	pyb.delay(50)

ifconfig = wlan.ifconfig()
print( "connected as: %s (%s)" % (ifconfig[0], ifconfig[5]) )
the server

Code: Select all

sock = ""
try:
	sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except:	
	print( "Failed to create socket" )
	sys.exit()
		
sock.bind(("", 8080))
sock.listen(5)
print( "Sever listening..." )
	
while True:
	try:
			
		csock, caddr = sock.accept()
						
		print("Connection from:", caddr[0])
		csock.send("Server running on the pyboard!!!\n")
			
		data = csock.recv(128)
		data = data.decode('utf-8')
			
		print("Query", data)
			
		csock.close()
			
		pyb.delay(10)
		print("Connection closed form", caddr[0])
			
	except OSError as er:

		print ("OSError", err)
		pyb.delay(500
I receive quite a lot OSError 1... no idea what that means.

Thanks for your help.

User avatar
polygontwist
Posts: 36
Joined: Sat Jun 28, 2014 4:54 pm
Location: Germany, Rostock
Contact:

Re: (Pyboard && CC3000) Server stops responding after a while

Post by polygontwist » Mon Feb 02, 2015 9:03 pm

I have the same problem. So far, it give no solution.
see: http://forum.micropython.org/viewtopic.php?f=2&t=485

Code: Select all

 sock.accept()
make the Errors....

Post Reply