rlotun / txwebsocket Goto Github PK
View Code? Open in Web Editor NEWTwisted WebSocket Server, based on http://twistedmatrix.com/trac/ticket/4173
Home Page: http://twistedmatrix.com/trac/ticket/4173
Twisted WebSocket Server, based on http://twistedmatrix.com/trac/ticket/4173
Home Page: http://twistedmatrix.com/trac/ticket/4173
The protocol mentions that the challenge must be computed with concatenation of the keys as "sent on the wire" (the client should shuffle the headers). The current version always takes the order Sec-WebSocket-Key1, Sec-WebSocket-Key2.
Hello,
Is there a way to get access to "connectionMade" so code can be ran when a socket is opened? I'm new to twisted and tried to expose this function, but couldn't figure it out. Thanks.
del for my websockethandler never gets called, the object is never freed even when connections are lost
I've encountered a bug. I can get clients to connect to the server via websockets but when the client disconnects there is an error :
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\twisted\python\log.py", line 84, in callWithLogger
return callWithContext({"system": lp}, func, _args, *_kw)
File "C:\Python27\lib\site-packages\twisted\python\log.py", line 69, in callWithContext
return context.call({ILogContext: newCtx}, func, _args, *_kw)
File "C:\Python27\lib\site-packages\twisted\python\context.py", line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, _args, *_kw)
File "C:\Python27\lib\site-packages\twisted\python\context.py", line 37, in callWithContext
return func(args,*kw)
--- ---
File "C:\Python27\lib\site-packages\twisted\internet\selectreactor.py", line 146, in _doReadOrWrite
why = getattr(selectable, method)()
File "C:\Python27\lib\site-packages\twisted\internet\tcp.py", line 460, in doRead
return self.protocol.dataReceived(data)
File "C:\Python27\lib\site-packages\twisted\protocols\basic.py", line 572, in dataReceived
return self.rawDataReceived(data)
File "C:\Python27\lib\site-packages\twisted\web\http.py", line 1645, in rawDataReceived
self._transferDecoder.dataReceived(data)
File "C:\Users\Clem\Desktop\3IF\fil rouge\ServeurPR\websocket.py", line 468, in dataReceived
if frame[0] != "\x00":
exceptions.IndexError: string index out of range
I'm using http://websocket.org/echo.html connecting to my local server. I can provide you if you want some network traces.
Is it possible to get this patched? It's just a minor "bonus" if it was possible. :)
Firefox 7.0.1 sets 'connection' header not to "Upgrade", but "keep-alive, Upgrade".
The next change in WebSocketRequest.process method fixes the problem:
57 line:
if connection != "Upgrade"
if connection not in ("Upgrade", "keep-alive, Upgrade")
For my project, I'd want to be able to put a factory in the Web Socket hierarchy. Could this be implemented?
I get the error ImportError: cannot import name _IdentityTransferDecoder. Google came up with no results. I have Python 2.7
Newest Chromium uses the hybi-10 version of the WebSocket protocol (http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10). See http://code.google.com/p/chromium/issues/detail?id=64470 for details.
Both the handshake and the payload format have changed and currently txWebSocket does not work with Chromium.
I'm working on implementing both tha handshake and the new frame format and will create a pull request as soon as I have it done.
In the simple_server.py example, I added only print "init" under the init method.
class Testhandler(WebSocketHandler):
def init(self, transport):
WebSocketHandler.init(self, transport)
self.periodic_call = task.LoopingCall(self.send_time)
print "init", self, transport
On the client-side this is the only code being executed:
var ws = new WebSocket("ws://109.74.200.181:8090/test");
ws.onopen = function()
{
alert('onopen fired!');
//ws.send("message to send");
};
(As you can see I changed the port in this example, but no other changes were made)
This causes output from ONE connection:
init <main.Testhandler object at 0x9e70a6c> <websocket.WebSocketTransport object at 0x9e7018c>
init <main.Testhandler object at 0x9e7062c> <websocket.WebSocketTransport object at 0x9e7018c>
I'm not good at this but it looks like there's two "selfs" or instances being made. And when the browser is being closed, connectionLost is only fired once. This has led to some strange behaviour in one of my applications. Users getting an increasing number of transports added to their "client", never getting cleaned out or "connectionLost".
Can you replicate this, or is it intended?
Following is the traceback from running the code.
Traceback (most recent call last):
File "simple_server.py", line 72, in <module>
site = WebSocketSite(root)
File "C:\Users\piyushdivyankar\Documents\Projects\asynchronous-programming\txW
ebSocket-master\txWebSocket-master\websocket.py", line 279, in __init__
Site.__init__(self, resource, logPath, timeout)
File "C:\Program Files\Anaconda2\lib\site-packages\twisted\web\server.py", lin
e 698, in __init__
http.HTTPFactory.__init__(self, *args, **kwargs)
File "C:\Program Files\Anaconda2\lib\site-packages\twisted\web\http.py", line
2789, in __init__
logPath = os.path.abspath(logPath)
File "C:\Program Files\Anaconda2\lib\ntpath.py", line 488, in abspath
path = _getfullpathname(path)
TypeError: coercing to Unicode: need string or buffer, int found
Tried to change the value of root to a string with absolute file path, but that didn't work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.