# Simple websocket server on Kong

**URL:** <https://discuss.konghq.com/t/simple-websocket-server-on-kong/6338>\
**Category:** Questions\
**Created:** [May 20, 2020, 6:24am UTC](https://discuss.konghq.com/t/simple-websocket-server-on-kong/6338 "2020-05-20T06:24:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orochi663](https://avatars.discourse-cdn.com/v4/letter/o/7993a0/32.png) [@Orochi663](https://discuss.konghq.com/u/Orochi663)\
**Post date:** [May 20, 2020, 6:24am UTC](https://discuss.konghq.com/t/simple-websocket-server-on-kong/6338/1 "2020-05-20T06:24:18Z")

</div>

Hi,  
I am a newbie to this realm of web services and gateways. I have gone through documentation and tried using kong on my local machine (Cent OS).

I have been trying to figure out how to configure a simple websocket server (hosted at localhost) like the echoserver(wss://echo.websocket.org) with Kong. I have tried

1. Added custom nginx.conf with pointers mentioned here ([https://github.com/Kong/kong/issues/218](https://github.com/Kong/kong/issues/218))  
in the `http` directive:

```auto
# Websocket
map $http_upgrade $connection_upgrade {
  default upgrade;
  '' close;
}

```

in the `server` directive:

```auto
proxy_http_version 1.1;

# Proxy Websocket Upgrade request
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

```

1. Added this to kong.yml  
services:

- name: echoserver  
url: [http://localhost:9002](http://localhost:9002)  
routes: myroute
  - name: echoserverroute  
paths:
    - /

But still i am not able to connect to it. I tried:  
wscat -c [http://localhost:9002](http://localhost:9002)

But it waits like forever to connect and when i press Ctrl+C it gives following error:  
“error: WebSocket was closed before the connection was established”

Help / guidance is needed. Kindly help on how to use Kong for a websocket service.

Regards.
