deepstreamIO / deepstream.io

deepstream.io server

Home Page:https://deepstreamio.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't connect to server using protobuf

geohuz opened this issue · comments

Server response always cause parse error then client get {topic: 1, action: 6} which is a parse error

I'm using the dummy-client-js from the repo: https://github.com/deepstreamIO/deepstream.io-dummy-client/blob/master/src/index.ts in my reactjs App and trying to connect server as a vanilla websocket client, but I can't establish connection with the server, the response message is always {topic: 1, action: 6}, which should be an error in message parse routine, as below:

TypeError: Cannot read properties of undefined (reading 'decode')

To Reproduce
using the code above in Reactjs and connect to deepstream server.

Expected behavior
Should connect

Server version
6.0.1

Protocol (binary or text)
binary

Websocket server (node-http or uws)
uws

Server OS
ubuntu

Node version

Server config
Please share the config sections that might be relevant for this issue

Client (Js, Java, other) and client version
Js 6.0.1

Client config
Please share the config sections that might be relevant for this issue

Additional context
Add any other context about the problem here.

I fixed my problem by setting the socket binary type:

socket.binaryType="arraybuffer"

and

  const message = parse(new Uint8Array(raw.data))[0]