Channels: 'unicode' object has no attribute 'parseStreamServer'

Created on 10 Jan 2017  Â·  7Comments  Â·  Source: django/channels

Howdy partners! First of all I would like to thank @andrewgodwin for such a great app and of course everyone who contributed as well.

I am receiving an error (traceback below) when I run ./manage.py runserver. The odd part is that if I run the server on any port other than 8000, it runs and works fine. For instance ./manage.py runserver localhost:8001 works perfectly fine. Another interesting aspect of this issue is that If I run daphne -p 8000 testproject.asgi:channel_layer then ./manage.py runworker everything seems to run fine. So the problem occurs only when I use runserver with port 8000 (default).

./manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
January 10, 2017 - 01:02:44
Django version 1.9.7, using settings 'testproject.settings'
Starting Channels development server at http://127.0.0.1:8000/
Channel layer default (asgiref.inmemory.ChannelLayer)
Quit the server with CONTROL-C.
2017-01-10 01:02:44,265 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-01-10 01:02:44,265 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-01-10 01:02:44,266 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-01-10 01:02:44,266 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-01-10 01:02:44,267 - INFO - server - Using busy-loop synchronous mode on channel layer
2017-01-10 01:02:44,267 - INFO - server - Listening on endpoint tcp:port=8000:interface=127.0.0.1
Unhandled exception in thread started by
Traceback (most recent call last):
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(args, *kwargs)
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.7/site-packages/channels/management/commands/runserver.py", line 89, in inner_run
root_path=getattr(settings, 'FORCE_SCRIPT_NAME', '') or '',
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.7/site-packages/daphne/server.py", line 96, in run
ep = serverFromString(reactor, socket_description)
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.7/site-packages/twisted/internet/endpoints.py", line 1522, in serverFromString
return _serverFromStringLegacy(reactor, description, _NO_DEFAULT)
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.7/site-packages/twisted/internet/endpoints.py", line 1438, in _serverFromStringLegacy
return plugin.parseStreamServer(reactor, args, *kw)
AttributeError: 'unicode' object has no attribute 'parseStreamServer'

Traceback is posted above.

Im using daphne 1.0, channels 1.0, django 1.9.7, asgiref 1.0, Im also using the InMemory layer.

please help.

bug exintermediate

Most helpful comment

Fixed in daphne version 1.0.1; update to that and it should work all the time. Let me know if it doesn't.

All 7 comments

+1, same issue from me. And thanks for sharing the temporary workaround,
using port 8001!

On Mon, Jan 9, 2017 at 4:04 PM, Arken94 notifications@github.com wrote:

Howdy partners! First of all I would like to thank @andrewgodwin
https://github.com/andrewgodwin for such a great app and of course
everyone who contributed as well.

I am receiving an error (traceback below) when I run ./manage.py runserver.
The odd part is that if I run the server on any port other than 8000, it
runs and works fine. For instance ./manage.py runserver localhost:8001
works perfectly fine. Another interesting aspect of this issue is that If I
run daphne -p 8000 django_project.asgi:channel_layer then ./manage.py
runworker everything seems to run fine. So the problem occurs only when I
use runserver with port 8000 (default).

./manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
January 10, 2017 - 01:02:44
Django version 1.9.7, using settings 'testproject.settings'
Starting Channels development server at http://127.0.0.1:8000/
Channel layer default (asgiref.inmemory.ChannelLayer)
Quit the server with CONTROL-C.
2017-01-10 01:02:44,265 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-01-10 01:02:44,265 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-01-10 01:02:44,266 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-01-10 01:02:44,266 - INFO - worker - Listening on channels
http.request, websocket.connect, websocket.disconnect, websocket.receive
2017-01-10 01:02:44,267 - INFO - server - Using busy-loop synchronous mode
on channel layer
2017-01-10 01:02:44,267 - INFO - server - Listening on endpoint
tcp:port=8000:interface=127.0.0.1
Unhandled exception in thread started by
Traceback (most recent call last):
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.
7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(args, *kwargs)
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.
7/site-packages/channels/management/commands/runserver.py", line 89, in
inner_run
root_path=getattr(settings, 'FORCE_SCRIPT_NAME', '') or '',
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.
7/site-packages/daphne/server.py", line 96, in run
ep = serverFromString(reactor, socket_description)
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.
7/site-packages/twisted/internet/endpoints.py", line 1522, in
serverFromString
return _serverFromStringLegacy(reactor, description, _NO_DEFAULT)
File "/Users/arkenibrahim/.virtualenvs/book/lib/python2.
7/site-packages/twisted/internet/endpoints.py", line 1438, in
_serverFromStringLegacy
return plugin.parseStreamServer(reactor, args, *kw)
AttributeError: 'unicode' object has no attribute 'parseStreamServer'

Traceback is posted above.

Im using daphne 1.0, channels 1.0, django 1.9.7, asgiref 1.0

please help.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/django/channels/issues/470, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAzNEqd_ThZdoy9fuzew66IMUTxPAHdyks5rQsr_gaJpZM4Le4Wy
.

Running on a vagrant VM:

First try:


python manage.py runserver 8000
...
Starting Channels development server at http://127.0.0.1:8000/
...
AttributeError: 'unicode' object has no attribute 'parseStreamServer'


Second try:


python manage.py runserver 8001
...
Starting Channels development server at http://127.0.0.1:8001/
....
AttributeError: 'unicode' object has no attribute 'parseStreamServer'


Third try:


python manage.py runserver localhost:8000
....
Starting Channels development server at http://localhost:8000/
....
NO ERRORS

Fourth try:


python manage.py runserver localhost:8001
...
Starting Channels development server at http://localhost:8001/
...
NO ERRORS

OK, I've traced this down to happening on Python 2 only, which is why I didn't see it in testing.

Fixed in daphne version 1.0.1; update to that and it should work all the time. Let me know if it doesn't.

Thanks a ton @andrewgodwin. I tried debugging the problem on my own a little and got stumped, do you think you could let me in on what the problem was?

It looks like the Twisted serverFromString method only expects a str under Python 2; the default in the runserver command is written as a string literal with unicode literals turned on, so it comes through as unicode and things explode. I mostly just tried different variations until I broke it, cast it to a str, and then made sure that worked under both versions.

Awesome speed.

Tested on p2.7 and p3.4 and working

Many thanks

Was this page helpful?
0 / 5 - 0 ratings