krakend / krakend-pubsub

a pubsub backend for the KrakenD framework
https://www.krakend.io
Apache License 2.0
10 stars 16 forks source link

Using Krakend Enterprise websocket with NATS #15

Closed jhontea closed 1 year ago

jhontea commented 2 years ago

Hi Everyone,

My team and I are quite new to krakend and we are having trouble connecting our nats server. We are using krakend enterprise with websocket connection and then we want to subscribe to NATS. Here our configuration:

{
    "version": 2,
    "host": [ "http://localhost:8080" ],
    "port": 8080,
    "endpoints": [
    {
      "endpoint": "/nws",
      "querystring_params":[ "*" ],
      "headers_to_pass":[ "*" ],
      "backend": [
        {
          "host": ["ws://localhost:9090"],
          "disable_host_sanitize": true,
          "extra_config": {
                "backend/pubsub/subscriber": {
                    "subscription_url": "foo"
                }
            }
        }
      ],
      "extra_config":{
        "github.com/devopsfaith/krakend-websocket": {
            "headers_to_pass":["Cookie", "Authorization"],
            "connect_event": true,
            "disconnect_event": true
        }
      }
    }
    ]
}

Error from our nats server

[29150] 2022/03/17 13:06:13.658419 [ERR] 127.0.0.1:37244 - wid:7688 - Client parser ERROR, state=0, i=0: proto='"{\"msg\":\"KrakenD WS proxy startin"...'
[29150] 2022/03/17 13:06:13.658577 [ERR] 127.0.0.1:37246 - wid:7689 - Client parser ERROR, state=0, i=0: proto='"{\"msg\":\"KrakenD WS proxy startin"...'
[29150] 2022/03/17 13:06:13.658762 [ERR] 127.0.0.1:37248 - wid:7690 - Client parser ERROR, state=0, i=0: proto='"{\"msg\":\"KrakenD WS proxy startin"...'
[29150] 2022/03/17 13:06:13.658964 [ERR] 127.0.0.1:37250 - wid:7691 - Client parser ERROR, state=0, i=0: proto='"{\"msg\":\"KrakenD WS proxy startin"...'
[29150] 2022/03/17 13:06:13.659119 [ERR] 127.0.0.1:37252 - wid:7692 - Client parser ERROR, state=0, i=0: proto='"{\"msg\":\"KrakenD WS proxy startin"...'
...

Error from krakend

022/03/17 13:06:13  DEBUG: [WS backend sent a response without an envelope: invalid character 'E' in numeric literal]
2022/03/17 13:06:13  DEBUG: [WS received msg: INFO {"server_id":"NBHQHP2JL7QCMSUHFGFMJQ2I2E7KNUSKSQI7WWABY5IE4WW7SS4CCAK7","server_name":"nats_local","version":"2.7.3","proto":1,"git_commit":"1712ee3","go":"go1.17.7","host":"0.0.0.0","port":4222,"headers":true,"max_payload":1048576,"jetstream":true,"client_id":7691,"client_ip":"127.0.0.1"} 
]
2022/03/17 13:06:13  DEBUG: [WS backend sent a response without an envelope: invalid character 'E' in numeric literal]
^C2022/03/17 13:06:13  DEBUG: [WS received msg: INFO {"server_id":"NBHQHP2JL7QCMSUHFGFMJQ2I2E7KNUSKSQI7WWABY5IE4WW7SS4CCAK7","server_name":"nats_local","version":"2.7.3","proto":1,"git_commit":"1712ee3","go":"go1.17.7","host":"0.0.0.0","port":4222,"headers":true,"max_payload":1048576,"jetstream":true,"client_id":7692,"client_ip":"127.0.0.1"} 
...

Is there any best practice to connect krakend and nats using websocket?

gedw99 commented 1 year ago

also need an answer on this, sos adding myself.

alombarte commented 1 year ago

Hi, for Enterprise related questions please contact with its support channel.

Open source repositories are not monitored by the Enterprise support team and do not have any SLA.