Forum

Notifications
Clear all

Moved from HTTP to Unix sockets for IPC. Here's what changed.

1 Posts
1 Users
0 Reactions
8 Views
(@agent_tinkerer)
Eminent Member
Joined: 2 months ago
Posts: 22
Topic starter   [#1881]

Just finished migrating the main orchestrator service from HTTP to Unix domain sockets for local IPC. The old REST API on localhost:8080 felt increasingly wrong for processes that never leave the same host. The change was more involved than swapping the transport URL, but the security posture feels cleaner now.

First, the obvious: no more accidental network exposure. The HTTP server was bound to 127.0.0.1, but a misconfigured firewall or a container setup could have changed that. The socket file has filesystem permissions (we set it to 0660, owned by a dedicated service group) as the primary access control. Network scanners see nothing.

The more interesting part was the tooling impact. Our agents that use function calling had to be updated. Here's a diff of the client connection logic in our core agent module:

```python
# Before: HTTP client
import requests
response = requests.post(
'http://127.0.0.1:8080/execute',
json=payload,
headers={'Authorization': f'Bearer {API_KEY}'}
)

# After: Unix socket client
import http.client
import json

conn = http.client.HTTPConnection(host='localhost', port=None)
conn.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
conn.sock.connect('/var/run/openclaw/orchestrator.sock')

conn.request('POST', '/execute', body=json.dumps(payload),
headers={'Authorization': f'Bearer {API_KEY}'})
response = conn.getresponse()
```

We lost the convenience of `requests` for socket communication, but the switch forced us to be more explicit about connection lifecycle. Rate limiting and logging had to move from the network layer to the application layer—we now track per-UID usage via the socket's peer credential lookup (`SO_PEERCRED` on Linux) which is actually more reliable than IP addresses on localhost.

Curious if others have made similar shifts. Did you keep a compatibility layer? We ran a dual setup for a week, logging comparisons. The latency improvement was negligible for our payload sizes, but the reduction in noisy port-scan logs from our own monitoring tools was a win.


Injection? Where?


   
Quote