Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
IT Security NachrichtenOnePlus/OxygenOS: Schad-App erhält Root-Zugriff ohne Berechtigungen(24.09.2026 um 23:38 Uhr)
•
IT Security NachrichtenRyuk Member Karen Vardanyan Sentenced to Two Years in U.S. Prison(24.09.2026 um 22:50 Uhr)
•••••
Hacking & PentestingRyuk Member Karen Vardanyan Sentenced to Two Years in U.S. Prison(24.09.2026 um 22:50 Uhr)
•
AI & KI NachrichtenWhy the U.N. Still Matters(24.09.2026 um 23:00 Uhr)
•••
IT Security NachrichtenOnePlus/OxygenOS: Schad-App erhält Root-Zugriff ohne Berechtigungen(24.09.2026 um 23:38 Uhr)
•
IT Security NachrichtenRyuk Member Karen Vardanyan Sentenced to Two Years in U.S. Prison(24.09.2026 um 22:50 Uhr)
•••••
Hacking & PentestingRyuk Member Karen Vardanyan Sentenced to Two Years in U.S. Prison(24.09.2026 um 22:50 Uhr)
•
AI & KI NachrichtenWhy the U.N. Still Matters(24.09.2026 um 23:00 Uhr)
•••
Intelligence View
⚡ tsecurity.de Intelligence

Understanding WebSocket in JavaScript

In a past blog post, I discussed using the fetch API to send requests to a server --- specifically, making HTTP requests to GET, POST, update data with PUT, or DELETE data. These are one-time, on-demand requests, which are particularly…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In a past blog post, I discussed using the fetch API to send requests to a server --- specifically, making HTTP requests to GET, POST, update data with PUT, or DELETE data. These are one-time, on-demand requests, which are particularly useful for working with static data.



However, when we need more frequent or continuous communication with a server, such as for a chat application or an online game, we can use a different approach: WebSocket.



The WebSocket API enables a two-way interactive communication session between a client and a server without the need for polling (constantly checking if new data is available).



There are several WebSocket API mechanisms:



WebSocket Interface

The WebSocket interface is stable, widely supported across browsers and servers, and easy to set up. Its main disadvantage is that it doesn't support backpressure (messages can arrive faster than the application can process, potentially leading to CPU overusage). However, for most simple, real-time applications, such as chat apps, this is usually not a problem.



WebSocketStream Interface

The WebSocketStream interface is a Promise-based and handles backpressure. However, it is not standardized and is only supported by one rendering engine.



WebTransport API

The WebTransport API is a newer, versatile low-level API and provides features that are not available in the WebSocket and WebSocketStream Interfaces. It is designed for more complex applications, such as video conferencing apps or online games. However, it is more complex to use and not widely supported.



Here, I'll take a closer look at WebSocket.



Constructor:




new WebSocket(url)






The WebSocket constructor creates a WebSocket object and immediately attempts to establish a connection to the specified WebSocket URL.

The URL must use one of the following protocols: ws, wss, http, or https.

ws: WebSocket (non-encrypted)

wss: Secure WebSocket (encrypted, similar to HTTPS)



Image of TCP Connection



Image description

Source: Wikipedia



Events

open:

The open event is fired when a WenSocket connection is successfully established. The onopen property is also available.



Example:




// Create WebSocket connection.
const socket = new WebSocket("ws://localhost:8080");

// Connection opened
socket.addEventListener("open", (event) => {
socket.send("Hello Server!");
});






MDN



message:

The message event is fired when data is received through a WebSocket connection. The onmessage property is also available.



Example:




// Listen for messages
socket.addEventListener("message", (event) => {
console.log("Message from server ", event.data);
});






MDN



The data is read-only and can be either a string or a binary type (ArrayBuffer or Blob).



error:

The error event is fired when a WebSocket connection is closed due to an error. The onerror property is also available.



Example:




// Listen for possible errors
socket.addEventListener("error", (event) => {
console.log("WebSocket error: ", event);
});






MDN



close:

The close event is fired when a WebSocket connection is closed. The onclose property is also available.



Example:




socket.addEventListener("close", (event) => {
console.log("The connection has been closed successfully.");
});






(The example has been modified for consistency.)

MDN



CloseEvent:

code property

The code property provides a numeric code indicating the reason for the WebSocket connection's closure.

1000 - Normal closure (default)

1001 - The endpoint is going away (e.g., server shutting down)

etc.

For a complete list of close codes, refer to MDN.



reason property

The reason property provides a human-readable string indicating the reason for closing the connection.



wasClean property

The wasClean property returns a boolean value: true if the connection was closed cleanly; false otherwise.



send() Method

The send() method is used to send data to a server through a WebSocket connection.



Example:




socket.send(data)






The data can be either a string or binary data (ArrayBuffer or Blob).



Rate Limiting

When sending a large amount of data over a slow internet connection, the send() method can be called multiple times. However, the data will be buffered (stored) in memory. This can be monitored using the bufferedAmount property.



Example:




// every 100ms examine the socket and send more data 
// only if all the existing data was sent out
setInterval(() => {
if (socket.bufferedAmount == 0) {
socket.send(moreData());
}
}, 100);






The Modern JavaScript Tutorial



WebSocket is a modern method for maintaining continuous communication with a server, without the limitations of cross-origin restrictions, and is widely supported by browsers. This opens up many possibilities for creating a variety of applications.

CTI Threat Relationship Graph2 Knoten / 1 Relationen
CVE / Incident Software MITRE ATT&CK CWE Weakness IoC
SOC Incident Playbook: Remote Code Execution (RCE) Defense
Syntax validiert (0 Fehler)
title: Detect Exploitation - Understanding WebSocket in JavaScript
id: 9cf2bb24-29d8-4d45-894e-1df9c7b3f5fd
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Understanding WebSocket in Jav" ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Understanding WebSocket in JavaScript")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Understanding WebSocket in JavaScript*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Understanding WebSocket in JavaScript"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc
🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Understanding WebSocket in JavaScript.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Understanding WebSocket in JavaScript

Thematisch verwandte Begriffe: Understanding, WebSocket, JavaScript · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-81473 | Dell Rugged Control Center (RCC), versions prior to 5.2.206, contain an …
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel • Rechts: nächster Artikel • unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...
↗ Original-Quelle