You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 5-network/11-websocket/article.md
+18-19Lines changed: 18 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,44 +14,43 @@ let socket = new WebSocket("ws://javascript.info");
14
14
C'è anche il protocollo criptat `wss://`, utilizzato per i websockets HTTPS
15
15
16
16
17
-
```smart header="Sceggli sempre wss://"
17
+
```smart header="Scegli sempre `wss://`"
18
18
Il procotollo `wss://` non solo è criptato, ma è anche più affidabile.
19
19
20
20
Questo perchè i dati del `ws://` non sono criptati, visibili per qualunque intermediario. Server proxy molto vecchi, che non riconoscono l'implementazione WebSocket, potrebbero notare i suoi headers strani e chiudere la connessione.
21
21
22
22
Invece, `wss://`è una connessione over TLS (lo stesso di HTTPS che è HTTP over TLS), TLS cripta il dato invio e lo decripta in ricezione. Così i dati passano attraverso i proxy in maniera criptata e non potendone vedere il contenuto lo lasciano passare.
23
23
```
24
+
Appena creato il socket, dovremmo rimanere in ascolto su di esso per gli eventi. Ce ne sono 4:
For demo purposes, there's a small server [server.js](demo/server.js)written in Node.js, for the example above, running. It responds with "Hello from server, John", then waits 5 seconds and closes the connection.
62
+
A scopo dimostrativo, c'è un piccolo server funzionante [server.js](demo/server.js)scritto in Node.js, per l'esempio qui sopra. Risponde con "Hello from server, John" quindi attende 5 secondi e chude la connessione.
64
63
65
-
So you'll see events`open` -> `message` -> `close`.
64
+
Quindi vedrai gli eventi`open` -> `message` -> `close`.
66
65
67
66
That's actually it, we can talk WebSocket already. Quite simple, isn't it?
0 commit comments