Skip to content

Commit bc81a17

Browse files
committed
Updated socket.io client urls and modified readme to reflect url requirements on localhost
1 parent 6f73ca5 commit bc81a17

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

desktop-helper-sample/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,17 @@ Once both components are launched, you should be greeted with `'Connected'` stat
8585
Since it's an embedded server, its worth noting that this only runs on `localhost` and only administers communication between a single instance of the helper app and the UXP plugin. By default, the websocket server runs on port `4040` and the Electron helper app is served from port `3000`.
8686

8787
Other than connecting with one another, the two components can also pass strings of text which get reflected in their `Received data from the helper` and `Received data from UXP` sections.
88+
89+
## Note On socket.io
90+
91+
Currently, this sample uses `127.0.0.1` to connect to the socket server in order to work on all platforms.
92+
93+
For Windows users, this can be changed to `localhost` with no errors.
94+
95+
However, for Mac users, the socket connection must be changed (in both `uxp/src/index.js` and `helper/src/components/SocketContext.jsx`) to bypass the client 'polling' phase:
96+
97+
```
98+
let socket = io('http://localhost:4040', { transports: ['websocket'] });
99+
```
100+
101+
In order for UXP to establish a connection to the socket server through `localhost`.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React, { createContext } from 'react';
22
import io from 'socket.io-client';
33

4-
export const socket = io('http://localhost:4040', {
5-
transports: ['websocket'],
6-
});
4+
export const socket = io('http://127.0.0.1:4040');
75

86
export const SocketContext = createContext();

desktop-helper-sample/uxp/src/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ entrypoints.setup({
1313
},
1414
});
1515

16-
let socket = io('http://localhost:4040', {
17-
transports: ['websocket'],
18-
});
16+
let socket = io('http://127.0.0.1:4040');
1917

2018
// Attempt to reconnect if server isn't running
2119
socket.on('connect_error', () => {

0 commit comments

Comments
 (0)