- Mon Nov 09, 2015 5:25 pm
#33587
inx wrote:okay.
just added the forward declarations to the examples.
I tried to connect to my RPI as a server.
The ESP is saying it does have a connection and is sending mesaages.
I doe receive an error on the raspberry:
Code: Select all[W 151109 23:19:58 iostream:425] Read error on 8: [Errno 104] Connection reset by peer
[W 151109 23:19:58 iostream:359] error on read
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/tornado/iostream.py", line 354, in _handle_read
if self._read_to_buffer() == 0:
File "/usr/lib/python2.7/dist-packages/tornado/iostream.py", line 421, in _read_to_buffer
chunk = self._read_from_socket()
File "/usr/lib/python2.7/dist-packages/tornado/iostream.py", line 402, in _read_from_socket
chunk = self.socket.recv(self.read_chunk_size)
error: [Errno 104] Connection reset by peer
I did write some code in Pytho for the server at the RPI.
The code is:
Code: Select all#!/usr/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import tornado.websocket
TestVar = ""
from tornado.options import define, options
define("port", default=222, help="run on the given port", type=int)
class WebSocketHandler(tornado.websocket.WebSocketHandler):
def open(self):
print 'new connection from : %s' % self.request.remote_ip
self.write_message("connected")
def on_message(self, message):
print 'message received : %s from ip %s' % (message, self.request.remote_ip)
TestVar = self.request.remote_ip + ' ' + message
self.write_message('message received : %s' % message)
print TestVar
def on_close(self):
print 'connection closed from : %s' % self.request.remote_ip
if __name__ == "__main__":
tornado.options.parse_command_line()
app = tornado.web.Application(
handlers=[
(r"/", WebSocketHandler)
]
)
httpServer = tornado.httpserver.HTTPServer(app)
httpServer.listen(options.port)
print "Listening on port:", options.port
tornado.ioloop.IOLoop.instance().start()
Do you see something I'm doing wrong?