br41nslug / directus-websocket-subscribe

An extension to subscribe to directus updates over a websocket.
MIT License
106 stars 13 forks source link

Invalid message type! Either get, post, patch, delete or subscribe expected #20

Closed loongmxbt closed 1 year ago

loongmxbt commented 1 year ago

Hi, there, I'm new to this extension, looks great and I can connect to my server. ws://127.0.0.1:8082/websocket

- Connection open
- Connecting to: ws://127.0.0.1:8082/websocket

But when I send a message, it shows the following error, I've tried GET/get

- Received: {
  "type": "ERROR",
  "data": "Invalid message type! Either get, post, patch, delete or subscribe expected"
}
- Sending message: {
  "type": "get",
  "collection": "myoffer",
  "query": {
    "fields": [
      "*"
    ],
    "limit": 5
  },
  "uid": "9a58ccda-3578-478b-b7be-52ed647ff9f1"
}
image

My Deps

  "dependencies": {
    "@elecerp/directus-extension-vgrid-echart": "^0.1.1",
    "directus": "9.23.4",
    "directus-extension-websocket-subscribe": "^3.0.10",
    "pg": "^8.7.3"
  }

My .env file

# Websocket
WEBSOCKET_PUBLIC='true'
WEBSOCKET_PATH="/websocket"
WEBSOCKET_SYSTEM=false
WEBSOCKET_CORE='true'
WEBSOCKET_CORE_GET='true'
WEBSOCKET_CORE_POST='true'
WEBSOCKET_CORE_PATCH='true'
WEBSOCKET_CORE_DELETE='true'
loongmxbt commented 1 year ago

Add some info. When I remove the following WEBSOCKET_CORE_GET = true lines, I can send the messages.

# Websocket
WEBSOCKET_PUBLIC='true'
WEBSOCKET_PATH="/websocket"
WEBSOCKET_SYSTEM=false
WEBSOCKET_CORE='true'
# WEBSOCKET_CORE_GET='true'
# WEBSOCKET_CORE_POST='true'
# WEBSOCKET_CORE_PATCH='true'
# WEBSOCKET_CORE_DELETE='true'