[Solved] Websocket client not connecting

I have a working setup on a Wemos D1 mini (ESP-12) that runs a webserver/dashboard on my LAN.
This setup is also an access point, so I can still access the system in case of power/LAN failure.
Currently this setup is not linked to the internet.

This master broadcasts (AP) light commands to several dumb clients over UDP.
I can connect with my PC (wired) and with WiFi devices (laptop/phone) via the home router to the STA
as well as directly to the AP. Any time, and when the LAN/power fails.

Now I want to add temporary clients to this AP, with other ESP-12 modules.
Maybe a day/night sensor, or presence sensors.
They should connect, push some data to the master, and disconnect.
Just like you connect with the smartphone to the AP, do your thing, close the tab.

Wrote this test sketch to test that.
Connects fine to the AP, but does not establish a websocket connection.
Just keeps printing “[WSc] Disconnected!”.

Not the sharpest tool in the shed when it comes to networking, so what am I missing here.

#include <ESP8266WiFi.h>
#include <WebSocketsClient.h>
const char* AP_SSID = "ABCDEFG";
const char* AP_PW = "12345678";
//IPAddress ip(192, 168, 4, 10), gateway(192, 168, 4, 1), subnet(255, 255, 255, 0); // fixed IP
WebSocketsClient webSocket;

void setup() {
  Serial.begin(74880); // this baudrate also prints module startup data
  Serial.printf("\r\nESP-12 chip ID: %d\r\n", ESP.getChipId());
  Serial.printf("Trying to connect to %s  ", AP_SSID);
  //WiFi.config(ip, gateway, subnet);
  WiFi.begin(AP_SSID, AP_PW);
  byte w8 = 0; // ticks
  while (WiFi.status() != WL_CONNECTED && w8++ < 20) {
  if (WiFi.status() == WL_CONNECTED) {
    Serial.printf("\tConnected to %s  channel %d strength %d%% (%ddBm)\r\n\tIP: %s\r\n", AP_SSID, WiFi.channel(), 2 * (WiFi.RSSI() + 100), WiFi.RSSI(), WiFi.localIP().toString().c_str());
    webSocket.begin("", 81); // IP/port for Ws
  } else {
    Serial.println("Connection failed");

void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
  switch (type) {
    case WStype_DISCONNECTED:
      Serial.printf("[WSc] Disconnected!\n");
    case WStype_CONNECTED: {
        Serial.printf("[WSc] Connected to url: %s\n",  payload);
        // send message to server when Connected
    case WStype_TEXT:
      Serial.printf("[WSc] get text: %s\n", payload);
      // send message to server
      // webSocket.sendTXT("message here");
    case WStype_BIN:
      Serial.printf("[WSc] get binary length: %u\n", length);
      hexdump(payload, length);
      // send data to server
      // webSocket.sendBIN(payload, length);

void loop() {

Basically solved.

webSocket.begin("", 81); // was blindly copied from an example
It must be the gateway of the AP,