Pulsar: Websocket example not working - Throwing Unexpected server response: 500

Created on 16 Jan 2019  路  4Comments  路  Source: apache/pulsar

Describe the bug
Since there's no client available for Node.js, I tried to using WebSocket API for creating producers/consumers. When I tried the example given in the documentation, it throws me the "Unexpected server response: 500" error.

To Reproduce
Steps to reproduce the behavior:

  1. Run "Pulsar standalone" in docker container(WebSocket service is enabled by default in standalone mode)
  2. Check the service is working fine by checking the admin REST APIs
  3. Run the Websocket (node.js) examples given here.
  4. You will be able to see the error.

Expected behavior
Should be able produce/consume messages using Websocket clients.

Screenshots
pulsar-websocket-error

Desktop (please complete the following information):

  • OS: Windows 10(but running pulsar in docker container)

Additional context
No

help wanted typbug

Most helpful comment

In addition to the create, tenant, namespace has to be able to be used by standalone.

$ bin/pulsar standalone
$ bin/pulsar-admin tenants create my-tenant --allowed-clusters standalone
$ bin/pulsar-admin namespaces create my-tenant/my-ns
$ bin/pulsar-admin namespaces set-clusters my-tenant/my-ns --clusters standalone

or you can update tenant, namespace default value public/default/my-topic1,
then run example.

All 4 comments

@pruthvivrp

in the example, it is using topic my-tenant/my-ns/my-topic1 ( "ws://localhost:8080/ws/v2/producer/persistent/my-tenant/my-ns/my-topic1"). Have you manually created tenant my-tenant and namespace my-ns?

In addition to the create, tenant, namespace has to be able to be used by standalone.

$ bin/pulsar standalone
$ bin/pulsar-admin tenants create my-tenant --allowed-clusters standalone
$ bin/pulsar-admin namespaces create my-tenant/my-ns
$ bin/pulsar-admin namespaces set-clusters my-tenant/my-ns --clusters standalone

or you can update tenant, namespace default value public/default/my-topic1,
then run example.

@sijie Yes you're right, I missed to create the tenants and topics.

@ambition119 It worked with the steps you have mentioned. Please update it in the documentation if possible.

@pruthvivrp cool. glad to hear that it works for you now.

Was this page helpful?
0 / 5 - 0 ratings