fix: use correct signal-cli default port 8080 and robust connectivity check

- Change default noise-signal-cli-address to port 8080 (signal-cli's --http default)
- Replace getVersion (not a valid JSON-RPC method) with noisePing probe
- noise-rpc-check now returns t on any valid JSON-RPC response
- Update README to reflect correct default port
This commit is contained in:
2026-06-10 10:44:20 -04:00
parent 6d8727ea05
commit 8d820432ff
3 changed files with 41 additions and 10 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ The project assumes a working installation of signal-cli and interfaces with tha
For SQLite access we use this library - https://github.com/pekingduck/emacs-sqlite3-api
We communicate with signal-cli via JSON-RPC over HTTP on localhost port 9128 by default but this can be configured by specifying =noise-signal-cli-address=
We communicate with signal-cli via JSON-RPC over HTTP on localhost port 8080 by default but this can be configured by specifying =noise-signal-cli-address=
** User Experience
@@ -61,7 +61,7 @@ Below are recipes for several popular Emacs package managers.
:protocol https)
:config
;; Optional: set a custom signal-cli address
;; (setq noise-signal-cli-address "http://localhost:9128")
;; (setq noise-signal-cli-address "http://localhost:8080")
;; Start Noise automatically
(noise-mode 1))
+33 -4
View File
@@ -83,10 +83,39 @@ Signals `noise-rpc-error` on JSON-RPC error or malformed response."
(defun noise-rpc-check ()
"Check connectivity to signal-cli.
Returns the version string on success.
Signals `noise-rpc-error` on failure."
(let ((result (noise-rpc-call "getVersion")))
(gethash "version" result)))
Returns t if the daemon responds (even with an error indicating a valid JSON-RPC endpoint).
Signals `noise-rpc-error` on connection failure or timeout."
;; signal-cli daemon doesn't have a dedicated ping/version RPC method.
;; We send a request for a purposefully invalid method. If we get back
;; a valid JSON-RPC error response, the daemon is running and reachable.
;; If we get a connection error, the daemon is not running.
(let* ((url-request-method "POST")
(url-request-extra-headers
'(("Content-Type" . "application/json")))
(url-request-data "{\"jsonrpc\":\"2.0\",\"method\":\"noisePing\",\"id\":0}")
(url (concat noise-signal-cli-address "/api/v1/rpc"))
(url-show-status nil)
(buf (condition-case nil
(url-retrieve-synchronously url t)
(error (signal 'noise-rpc-error
(list (format "Could not connect to signal-cli at %s. Is signal-cli daemon running?"
noise-signal-cli-address)))))))
(if (not buf)
(signal 'noise-rpc-error (list (format "No response from signal-cli at %s" noise-signal-cli-address)))
(unwind-protect
(with-current-buffer buf
(goto-char (point-min))
(re-search-forward "\n\n" nil t)
(let* ((body (buffer-substring (point) (point-max)))
(parsed (condition-case nil
(json-parse-string body)
(error (signal 'noise-rpc-error
(list "signal-cli returned invalid JSON response"))))))
;; Any valid JSON-RPC response means the daemon is alive
(if (or (gethash "result" parsed) (gethash "error" parsed))
t
(signal 'noise-rpc-error (list "Invalid JSON-RPC response from signal-cli")))))
(kill-buffer buf)))))
(provide 'noise-rpc)
;;; noise-rpc.el ends here
+6 -4
View File
@@ -19,9 +19,10 @@
:group 'comm
:prefix "noise-")
(defcustom noise-signal-cli-address "http://localhost:9128"
(defcustom noise-signal-cli-address "http://localhost:8080"
"Base URL of the signal-cli JSON-RPC daemon.
Format: http://HOST:PORT"
Format: http://HOST:PORT
The default port is 8080, matching signal-cli's `--http` default."
:type 'string
:group 'noise)
@@ -30,8 +31,9 @@ Format: http://HOST:PORT"
"Check connectivity to the signal-cli JSON-RPC daemon."
(interactive)
(condition-case err
(let ((version (noise-rpc-check)))
(message "signal-cli connected (version %s)" version))
(progn
(noise-rpc-check)
(message "signal-cli connected at %s" noise-signal-cli-address))
(noise-rpc-error
(message "Error: %s" (cdr err)))))