deepstreamIO / deepstream.io

deepstream.io server
https://deepstreamio.github.io
MIT License
7.13k stars 382 forks source link

Received an invalid message type on uuid #1114

Closed calebklc closed 2 years ago

calebklc commented 2 years ago

Hi, I'm new to deepstream.io. I'm trying to start with simple application but I am getting below error.

I'm using

      _                     _ 
   __| | ___  ___ _ __  ___| |_ _ __ ___  __ _ _ __ ____ 
  / _` |/ _ \/ _ \ '_ \/ __| __| '__/ _ \/ _` | '_ ` _  \
 | (_| |  __/  __/ |_) \__ \ |_| | |  __/ (_| | | | | | |
  \__,_|\___|\___| .__/|___/\__|_|  \___|\__,_|_| |_| |_|
                 |_|
=====================   starting   =====================
INFO | logger ready: std out/err at level INFO
INFO | server name: kysizbi1-1y320bjiov5s
INFO | deepstream version: 6.0.1
INFO | configuration file loaded from conf/config.yml
CLUSTER_JOIN | kysizbi1-1y320bjiov5s
CLUSTER_SIZE | The cluster size is now 1
TELEMETRY | INFO | Telemetry disabled
INFO | monitoring ready: Noop Monitoring
INFO | subscriptions ready: Subscription Registry
INFO | storage ready: Noop Storage
INFO | cache ready: Local Cache
INFO | permission ready: none
INFO | locks ready: Distributed Lock Registry
INFO | clusterNode ready: Single Cluster Node
INFO | clusterRegistry ready: Distributed Cluster Registry
INFO | clusterStates ready: Distributed State Registry
INFO | telemetry ready: Deepstream Telemetry
INFO | authentication ready: Open Authentication
INFO | httpService ready: UWS HTTP Service
INFO | connectionEndpoint ready: WS Text Connection Endpoint
INFO | Deepstream started
INCOMING_CONNECTION | from  (127.0.0.1)
ERROR | Received an invalid message type on 0.5532479924693985
CLIENT_DISCONNECTED | null
INCOMING_CONNECTION | from  (127.0.0.1)
ERROR | Received an invalid message type on 0.5430133643790809
CLIENT_DISCONNECTED | null
INCOMING_CONNECTION | from  (127.0.0.1)
ERROR | Received an invalid message type on 0.7769814433032094
CLIENT_DISCONNECTED | null

Here is my config:

conf/config.yml

# General
# Each server within a cluster needs a unique name. Set to UUID to have deepstream autogenerate a unique id
serverName: UUID
# Show the deepstream logo on startup
showLogo: true
# Plugin startup timeout – deepstream init will fail if any plugins fail to emit a 'done' event within this timeout
dependencyInitializationTimeout: 5000
# Directory where all plugins reside
#libDir: ../lib
# Exit the process a fatal error occurs, like losing a cache connection
exitOnFatalError: false

# This disables specific feature in DS, which is a more performant way
# than disabling via permissions and is also how telemetry figures out
# what features are enabled
enabledFeatures:
  record: true
  # event: true
  # rpc: true
  # presence: true

record:
  # Maximum time permitted to fetch from cache
  cacheRetrievalTimeout: 30000
  # Maximum time permitted to fetch from storage
  storageRetrievalTimeout: 30000
  # A list of prefixes that, when a record starts with one of the prefixes the
  # records data won't be stored in the db
  # storageExclusionPrefixes:
  #   - no-storage/
  #   - temporary-data/
  # A list of prefixes that, when a record is updated via setData and it matches one of the prefixes
  # it will be permissioned and written directly to the cache and storage layers
  # storageHotPathPrefixes:
  #   - analytics/
  #   - metrics/

httpServer:
  type: uws
  options:
    # url path for http health-checks, GET requests to this path will return 200 if deepstream is alive
    healthCheckPath: /health-check

connectionEndpoints:
  - type: ws-json
    options:
      # url path websocket connections connect to
      urlPath: /deepstream-json
      # the amount of milliseconds between each ping/heartbeat message
      heartbeatInterval: 30000
      # the amount of milliseconds that writes to sockets are buffered
      outgoingBufferTimeout: 10
      # the maximum amount of bytes to buffer before flushing, stops the client from large enough packages
      # to block its responsiveness
      maxBufferByteSize: 100000

      # Security
      # amount of time a connection can remain open while not being logged in
      unauthenticatedClientTimeout: 180000
      # invalid login attempts before the connection is cut
      maxAuthAttempts: 3
      # maximum allowed size of an individual message in bytes
      maxMessageSize: 1048576

# Logger Configuration
logger:
  # use the default logger, this does not currently support meta objects
  type: default
  options:
    colors: true
    # Log messages with this level and above. Valid levels are DEBUG, INFO, WARN, ERROR, OFF
    logLevel: INFO

# Authentication
auth:
  - type: none

monitoring:
  type: none

server.js

const { Deepstream } = require('@deepstream/server');

const server = new Deepstream();

server.start();

client.js

const { DeepstreamClient } = require('@deepstream/client');
const client = new DeepstreamClient('localhost:6020/deepstream-json');

async function main() {
  try {
    await client.login();
  } catch (err) {
    console.error(err);
  }
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
jaime-ez commented 2 years ago

Hi, first of all, there are some documentation inconsistencies that I hope will be fixed soon.

About your code:

Using the json-transport is discouraged. Look here: https://deepstream.io/tutorials/plugins/connection-endpoint/websocket-json/ However If you use it you must initiate the client with the jsonTransportMode option as stated in that page.

Where is your config file located? The thing is that you are mixing the node api with the cli config file so to speak...when starting the server via the node api the best option is to pass the config object directly into the constructor:

const server = new Deepstream({...options});

I wouldn't suggest to pass null, it tries to look for the config file in series of paths that are harder to predict since it depends on where the process is being called from etc..

if you wish to use the yaml config file just start the server using the binary via CLI

Let me know if this helps

calebklc commented 2 years ago

It works after adding the jsonTransportMode option.

The config file is located at conf directory in project root but you're right, I should use the constructor way to load the config.

Thanks for your help and great explanation.

jaime-ez commented 2 years ago

glad it worked