Problem with setting server url 'path'

#1

Hi,

I would like to setup my WebSocket server with url like “ws://localhost:8080/test”.

Here is part of my code:

factory = WebSocketServerFactory(“ws://localhost:8080/test”, debug = False)

When I run the server, I encountered error as follows.

Traceback (most recent call last):

File “testing.py”, line 15, in

factory = WebSocketServerFactory("ws://localhost:8080/test", debug = False)

File “/usr/lib/python2.6/site-packages/autobahn-0.5.9-py2.6.egg/autobahn/websocket.py”, line 2974, in init

self.setSessionParameters(url, protocols, server, externalPort)

File “/usr/lib/python2.6/site-packages/autobahn-0.5.9-py2.6.egg/autobahn/websocket.py”, line 3002, in setSessionParameters

raise Exception("path specified for server WebSocket URL")

Exception: path specified for server WebSocket URL

How can I setup the server with path?

Thanks a lot.

0 Likes

#2

Here is part of my code:

factory = WebSocketServerFactory(“ws://localhost:8080/test”, debug = False)

I don’t think you can do that - and what would be the use case? You can specify endpoint paths using registerForRpc method.

0 Likes

#3

Here is part of my code:

        factory = WebSocketServerFactory("ws://localhost:8080/test",
        debug = False)

I don't think you can do that - and what would be the use case? You can
specify endpoint paths using registerForRpc method.

Well, you can. The URI provided is parsed to automatically determine the port, hostname, WS subpath the server will listen on

···

Am 06.02.2013 01:07, schrieb Karlo L.:

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#4

All,

I actually had the same question as the original poster and I don’t quite understand the responses.

The question is…is this possible? If it is, then why is there an error message (the OP gets the same one I do). If it isn’t, why not?

Ultimately, what I’m trying to do is to support more than one protocol on a single port. I thought this would be a reasonable way to do it (i.e. associate different paths with different protocols). If there is another way, please let me know. Keep in mind, I’m not interested in WAMP or RPC functionality. I’d like to stick with just basic WebSocket stuff.

Thanks.

···


Mike

On Wednesday, February 6, 2013 5:11:09 AM UTC-5, Tobias Oberstein wrote:

Am 06.02.2013 01:07, schrieb Karlo L.:

Here is part of my code:

    factory = WebSocketServerFactory("ws://localhost:8080/test",
    debug = False)

I don’t think you can do that - and what would be the use case? You can
specify endpoint paths using registerForRpc method.

Well, you can. The URI provided is parsed to automatically determine the
port, hostname, WS subpath the server will listen on


You received this message because you are subscribed to the Google
Groups “Autobahn” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#5

I looked into this a little further. I don’t quite understand Tobias’ response. I looked at the code on GitHub and it seems to very explicitly disallow a path component in the URI during initialization.

But it is confusing because the documentation for setSessionParameters doesn’t mention path, e.g.

:param url: WebSocket listening URL - ("ws:" | "wss:") "//" host [ ":" port ].

But the documentation for WebSocketServerFactory implies path is allowed, e.g.

:param url: WebSocket listening URL - ("ws:" | "wss:") "//" host [ ":" port ] path [ "?" query ].

Since the url is passed directly from the WebSocketServerFactory constructor to the setSessionParameters, it seems like the documentation should be updated so it is consistent.

But I guess the answer to my original question is, that you cannot disambiguate protocols using a path. So any other suggestions on how to support multiple protocols on a single port? (and by protocols, I mean WebSocketServerProtocols).

Thanks.

···


Mike

On Monday, March 25, 2013 6:02:04 PM UTC-4, Michael Tiller wrote:

All,

I actually had the same question as the original poster and I don’t quite understand the responses.

The question is…is this possible? If it is, then why is there an error message (the OP gets the same one I do). If it isn’t, why not?

Ultimately, what I’m trying to do is to support more than one protocol on a single port. I thought this would be a reasonable way to do it (i.e. associate different paths with different protocols). If there is another way, please let me know. Keep in mind, I’m not interested in WAMP or RPC functionality. I’d like to stick with just basic WebSocket stuff.

Thanks.


Mike

On Wednesday, February 6, 2013 5:11:09 AM UTC-5, Tobias Oberstein wrote:

Am 06.02.2013 01:07, schrieb Karlo L.:

Here is part of my code:

    factory = WebSocketServerFactory("ws://localhost:8080/test",
    debug = False)

I don’t think you can do that - and what would be the use case? You can
specify endpoint paths using registerForRpc method.

Well, you can. The URI provided is parsed to automatically determine the
port, hostname, WS subpath the server will listen on


You received this message because you are subscribed to the Google
Groups “Autobahn” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Likes

#6

I looked into this a little further. I don't quite understand Tobias'
response. I looked at the code on GitHub and it seems to very
explicitly disallow a path component in the URI during initialization.

But it is confusing because the documentation for setSessionParameters
doesn't mention path, e.g.

:param url: WebSocket listening URL - ("ws:" | "wss:") "//" host [ ":" port ].

But the documentation for WebSocketServerFactory implies path is
allowed, e.g.

:param url: WebSocket listening URL - ("ws:" | "wss:") "//" host [ ":" port ] path [ "?" query ].

Since the url is passed directly from the WebSocketServerFactory
constructor to the setSessionParameters, it seems like the documentation
should be updated so it is consistent.

Thanks! This is a documentation bug. For servers, path/query are not allowed for the listening URL. Neither in the constructor nor in setSessionParameters. The URL is only theer to determine hostname, port and scheme (ws/wss).

But I guess the answer to my original question is, that you cannot
disambiguate protocols using a path. So any other suggestions on how to
support multiple protocols on a single port? (and by protocols, I mean
WebSocketServerProtocols).

You have 2 options .. I have created examples .. pls check out if that helps:

https://github.com/tavendo/AutobahnPython/tree/master/examples/websocket/multiproto

- Tobias

0 Likes

#7

Tobias,

You have 2 options … I have created examples … pls check out if that
helps:

https://github.com/tavendo/AutobahnPython/tree/master/examples/websocket/multiproto

Excellent! I think both approaches may come in handy. I was thinking about exactly this issue of how to use parameters or headers to decide on protocol. But I think for now my main need is satisfied quite cleanly by your server2.py example.

Thanks for the quick response and the sample code!

···

On Tuesday, March 26, 2013 7:17:34 AM UTC-4, Tobias Oberstein wrote:

  • Tobias


Mike

0 Likes