---
title: "Binance WebSocket Proxy Socks Example | Siebly"
description: "Binance Misc websocket proxy socks JavaScript example for the Siebly Binance SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs."
canonical: "https://siebly.io/examples/Binance/WebSockets/Misc/ws-proxy-socks"
robots: "index,follow"
---

# Binance WebSocket Proxy Socks Example

Binance Misc websocket proxy socks JavaScript example for the Siebly Binance SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

**Path:** [Home](/) / [Examples](/examples) / [Binance](/examples/Binance) / [WebSockets](/examples/Binance/WebSockets) / [Misc](/examples/Binance/WebSockets/Misc) / [ws-proxy-socks.ts](/examples/Binance/WebSockets/Misc/ws-proxy-socks)

[View source on GitHub](https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Binance/WebSockets/Misc/ws-proxy-socks.ts)

[Open the Binance JavaScript SDK guide](/sdk/binance/javascript)

## ws-proxy-socks.ts

```typescript
/**
 * Minimal example for using a socks proxy with the ws client, extracted from https://github.com/tiagosiebler/binance/pull/319
 */
import { WebsocketClient } from 'binance';
import { SocksProxyAgent } from 'socks-proxy-agent';
// const { SocksProxyAgent } = require('socks-proxy-agent');

const agent = new SocksProxyAgent(process.env.http_proxy || '');
const wsClient = new WebsocketClient({
  beautify: true,
  wsOptions: {
    agent: agent,
  },
});

wsClient.on('formattedMessage', (data) => {
  console.log('log formattedMessage: ', data);
});
wsClient.on('open', (data) => {
  console.log('connection opened open:', data.wsKey, data.wsUrl);
});

wsClient.on('response', (data) => {
  console.log('log response: ', JSON.stringify(data, null, 2));
});
wsClient.on('reconnecting', (data) => {
  console.log('ws automatically reconnecting.... ', data?.wsKey);
});
wsClient.on('reconnected', (data) => {
  console.log('ws has reconnected ', data?.wsKey);
});

wsClient.subscribeAll24hrTickers('usdm');
```
