Can a websocket connection be made in Google app scripts? I wasn't able to find anything about these in Google's documentation, so I am unsure.
The answer is (sadly) still NO.
However, you can star this feature on apps script's issue tracker here - https://issuetracker.google.com/issues/117437427
You can however poll server-side functions using client-side asynchronous JavaScript API using google.script.run
. More on it could be found here - https://developers.google.com/apps-script/guides/html/reference/run
Just adding to Sourabh's answer, although you can't directly use websocket through Google Scripts, you can use it with Javascript.
https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
In order to use this, you need to create an html in which you can create your websocket.
https://developers.google.com/apps-script/guides/html/
For example:
<!DOCTYPE html>
<html>
<head>
<title>WebSocket demo</title>
</head>
<body>
<script>
let ws = new WebSocket("ws:port");
ws.onopen = () => ws.send("some message to send); // Sending a message
ws.onmessage = (event) => google.script.run.some_function(event.data); // Receiving a message
</script>
</body>
</html>
So you could either make a web app with google or just an html window with google scripts and embed the websocket in it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With