FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour PoC: Harbour โ†” Python via WebSocket (just like Node.js)
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
PoC: Harbour โ†” Python via WebSocket (just like Node.js)
Posted: Wed Jan 07, 2026 07:38 AM

Hello friends,

after connecting Harbour to Node.js via WebSocket, I will try the next obvious step:

Python can talk to Harbour via WebSocket in exactly the same way.

No tricks.
No frameworks.
No global installs.

โœ” bidirectional
โœ” stateful
โœ” portable
โœ” no registry
โœ” no global runtime

Harbour โ†” WebSocket โ†” Python is technically just as clean as Harbour โ†” Node.js.


---

Why this works today (and was unthinkable years ago)

Back then (Crystal Reports, COM, DLLs):

  • global runtimes
  • version conflicts
  • mandatory installers
  • hard to support

Today (Node / Python / Harbour):

  • everything runs in user space
  • each runtime is isolated
  • WebSocket is a clear contract
  • processes are replaceable

👉 The operating system is just transport now.


---

Python + WebSocket: typical setup

Python has very stable WebSocket libraries:

  • websockets (async, very common)
  • aiohttp
  • FastAPI (for larger services)

---

Minimal Python WebSocket server

Code (python): Select all Collapse
# ws_python_server.py
import asyncio
import websockets
import json

async def handler(ws):
    print("client connected")
    async for msg in ws:
        print("RX:", msg)
        data = json.loads(msg)

        if data.get("cmd") == "VERSION":
            reply = {
                "engine": "python",
                "version": "3.12",
                "msg": "hello from python"
            }
            await ws.send(json.dumps(reply))

async def main():
    async with websockets.serve(handler, "127.0.0.1", 8083):
        print("Python WS server on ws://127.0.0.1:8083")
        await asyncio.Future()

asyncio.run(main())

Start with:

python ws_python_server.py

---

Harbour side: no change needed

The Harbour WebSocket client:

  • does not know if the backend is Node or Python
  • speaks the same protocol
  • uses the same code
Code (harbour): Select all Collapse
ws_send_text( '{ "cmd": "VERSION" }' )
cReply := ws_recv_text()

Reply:

Code (json): Select all Collapse
{
  "engine": "python",
  "version": "3.12",
  "msg": "hello from python"
}

---

Why this is architecturally strong

You now have:

Harbour
   โ†” WebSocket (JSON)
       โ†” Node.js   (SQL, PDF, Web)
       โ†” Python    (AI, ML, statistics)
       โ†” other services

Harbour does not decide how something is done โ€”
only what is needed.


---

When Python makes more sense than Node.js

TaskBetter
SQL / APIs / PDFNode.js
AI / ML / statisticsPython
NumPy / PandasPython
Web renderingNode.js
Prototypingboth

👉 WebSocket makes the language interchangeable.


---

Portable Python: same surprise as Node.js

Yes, Python can also be:

  • portable
  • no installer
  • no registry
  • local folder only

Example:

/python
  python.exe
  Lib/
  ws_service.py

Start โ†’ works.

Exactly like Node.js.


---

Conclusion

This PoC shows that Harbour can integrate with multiple modern runtimes in a clean, understandable way.

No rewrites.
No global dependencies.
Just a clear interface.
Best regards,
Otto

Continue the discussion