Skip to content

HTTP Server (non-SSL) hangs on Linux - OnGet event never fires - Windows Work #165

@SpyOO

Description

@SpyOO

Hello,

I'm having trouble getting the TCrossWebSocketServer (from the Delphi-Cross-Socket library) to work on Linux. It works perfectly on Windows 11.

My goal is to run a non-SSL HTTP server (Create(2, False)).

The Environment

Delphi: Delphi 11

Linux: Alma Linux 8 (RHEL 8 clone)

DCS Library: Latest version from GitHub.

OpenSSL: System version is 1.1. (compat-openssl11 is installed).

The Problem

The server starts correctly and opens the port (I can see this in the OnServerListen log and netstat).

However, when I try to connect from a client (like wget http://127.0.0.1:8080), the client connects successfully but then hangs, "awaiting response" indefinitely.

Crucially, the server never fires the OnGet event. The log message inside LServer.Get('/', ...) is never printed.

What I've Tested

  • Windows 11: The exact same minimal test project (code below) works perfectly.

  • Oracle Linux 8 (VM): Fails (hangs).

  • Alma Linux 9 (WSL): Fails (hangs).

  • Firewall: The firewall (firewalld) is disabled on the Linux machine.

  • Indy Test: A separate TIdTCPServer (Indy) on port 9000 in the same application works perfectly on Linux. The problem seems specific to the DCS library.

  • Official Demo: I also tested the official WebSocketServer.dpr demo. It works on Windows (using wss://) but fails with the same hang on Linux.

Minimal Test Code (DCSTest.dpr)

This is the minimal console application I am using to test. It has no threads, no critical sections, and no other libraries.

program DCSTest;

{$APPTYPE CONSOLE}

uses
  System.SysUtils,
  Net.CrossSocket.Base,
  Net.CrossHttpServer,
  Net.CrossWebSocketServer,
  Net.CrossWebSocketParser;

var
  LServer: ICrossWebSocketServer;

begin
  Writeln('[DCS TEST] Starting test server...');

  try
    LServer := TCrossWebSocketServer.Create(2, False); // Non-SSL
    LServer.Port := 8080;

    LServer.Start(
      procedure(const AListen: ICrossListen; const ASuccess: Boolean)
      begin
        if ASuccess then
          Writeln('[DCS TEST] SERVER STARTED on [', AListen.LocalAddr, ':', AListen.LocalPort, ']')
        else
          Writeln('[DCS TEST] ERROR: Server could not start.');
      end);

    LServer.Get('/',
      procedure(const ARequest: ICrossHttpRequest; const AResponse: ICrossHttpResponse; var AHandled: Boolean)
      begin
        // --- THIS LOG NEVER APPEARS ON LINUX ---
        Writeln('[DCS TEST] HTTP GET Request Received!');
        AResponse.ContentType := 'text/html';
        AResponse.Send('<html><body><h1>DCS Test OK</h1></body></html>');
        AHandled := True;
      end);

    Writeln('[DCS TEST] Server is running. Press Enter to exit.');
    Readln;

    LServer.Stop;
    LServer := nil;

  except
    on E: Exception do
      Writeln('FATAL ERROR: ' + E.Message);
  end;
  Writeln('[DCS TEST] Exiting.');
end.

Log output on Linux:

[DCS TEST] Starting test server...
[DCS TEST] SERVER STARTED on [0.0.0.0:8080]
[DCS TEST] SERVER STARTED on [:::8080]
[DCS TEST] Server is running. Press Enter to exit.
(Hangs here. wget connects, but the "HTTP GET Request Received!" log never appears)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions