signal-cli icon indicating copy to clipboard operation
signal-cli copied to clipboard

GetUserStatus problem

Open Tsjippy opened this issue 1 year ago • 3 comments

I use JsonRpc via a unix socket, but I do not get any response for the GetUserStatus command.

This works: echo '{"jsonrpc":"2.0","method":"getUserStatus","params":{"recipient":["+SOMENUMBER"]},"id":6}' | signal-cli jsonRpc

This works too: printf '{"jsonrpc":"2.0","method":"send","params":{"recipient":["+SOMENUMBER"],"message":"hi"},"id":6}' | socat UNIX-CONNECT:/home/simnige1/sockets/signal -

But this does not work, no response, not even an error printf '{"jsonrpc":"2.0","method":"getUserStatus","params":{"recipient":["+SOMENUMBER"]},"id":6}' | socat UNIX-CONNECT:/home/simnige1/sockets/signal -

If I make however a deliberate mistake in the command like this: printf '{"jsonrpc":"2.0","method":"getUserStatus","params":{"recipien":["+SOMENUMBER"]},"id":6}' | socat UNIX-CONNECT:/home/simnige1/sockets/signal -

I get a response, although emty because I did not use command properly: {"jsonrpc":"2.0","result":[],"id":6}

How can I make it work?

Tsjippy avatar Jun 10 '24 07:06 Tsjippy

Your exact command works for me. So it looks like something with the CDSI request might hang or dead lock. However it's strange that it works with the signal-cli jsonRpc command ... Can you provide a verbose log (-vv) of the signal-cli daemon, that might shed some light on what's going on.

AsamK avatar Jun 10 '24 15:06 AsamK

This is the relevant portion of the log:

2024-06-12T03:12:01.013-0600 [daemon-listener] INFO  o.asamk.signal.jsonrpc.SocketHandler - Accepted new client connection 1:  UnixDomainPrincipal[user=simnige1, group=simnige1]
2024-06-12T03:12:01.014-0600 [pool-8-thread-1] TRACE o.asamk.signal.jsonrpc.JsonRpcReader - Incoming JSON-RPC message: {"jsonrpc":"2.0","method":"getUserStatus","params":{"recipient":["+SOMENUMBER"]},"id":6}
2024-06-12T03:12:01.015-0600 [pool-8-thread-1] TRACE o.asamk.signal.jsonrpc.JsonRpcReader - Reached end of JSON-RPC input stream.
2024-06-12T03:12:01.015-0600 [pool-10-thread-1] DEBUG o.asamk.signal.jsonrpc.JsonRpcReader - Received json rpc request, method: getUserStatus
2024-06-12T03:12:01.017-0600 [pool-10-thread-1] WARN  LibSignal - [PhoneNumberFormatter]: Got local CC: NG
2024-06-12T03:12:01.017-0600 [pool-10-thread-1] DEBUG o.a.s.manager.internal.ManagerImpl - Normalized number +SOMENUMBER to +.
2024-06-12T03:12:01.017-0600 [pool-10-thread-1] TRACE o.a.s.manager.helper.RecipientHelper - Querying CDSI for 1 new numbers (0 previous), isPartialRefresh=true
2024-06-12T03:12:01.019-0600 [pool-10-thread-1] INFO  LibSignal - [libsignal]: rust/bridge/shared/src/net.rs:86: Initializing connection manager for Prod...
2024-06-12T03:12:01.280-0600 [pool-8-thread-1] INFO  o.asamk.signal.jsonrpc.SocketHandler - Connection 1 closed:  UnixDomainPrincipal[user=simnige1, group=simnige1]
2024-06-12T03:12:06.070-0600 [Thread-2] INFO  LibSignal - [OkHttpWebSocketConnection]: [normal:1355321530] Sending keep alive...
2024-06-12T03:12:06.070-0600 [Thread-2] INFO  LibSignal - [OkHttpWebSocketConnection]: [unidentified:1145959531] Sending keep alive...
2024-06-12T03:12:06.206-0600 [receive-0] DEBUG o.a.s.manager.helper.ReceiveHelper - Checking for new message from server
2024-06-12T03:12:19.587-0600 [daemon-listener] INFO  o.asamk.signal.jsonrpc.SocketHandler - Accepted new client connection 2:  UnixDomainPrincipal[user=simnige1, group=simnige1]
2024-06-12T03:12:19.588-0600 [pool-8-thread-1] TRACE o.asamk.signal.jsonrpc.JsonRpcReader - Incoming JSON-RPC message: {"jsonrpc":"2.0","method":"getUserStatus","params":{"recipient":["+2349045252526"]},"id":6}
2024-06-12T03:12:19.589-0600 [pool-8-thread-1] TRACE o.asamk.signal.jsonrpc.JsonRpcReader - Reached end of JSON-RPC input stream.
2024-06-12T03:12:19.589-0600 [pool-11-thread-1] DEBUG o.asamk.signal.jsonrpc.JsonRpcReader - Received json rpc request, method: getUserStatus
2024-06-12T03:12:19.589-0600 [pool-11-thread-1] WARN  LibSignal - [PhoneNumberFormatter]: Got local CC: NG
2024-06-12T03:12:19.589-0600 [pool-11-thread-1] TRACE o.a.s.manager.helper.RecipientHelper - Querying CDSI for 1 new numbers (0 previous), isPartialRefresh=true
2024-06-12T03:12:20.401-0600 [System-3] INFO  LibSignal - [libsignal]: rust/attest/src/enclave.rs:119: Successfully completed attested connection
2024-06-12T03:12:20.787-0600 [pool-11-thread-1] DEBUG o.a.s.manager.helper.RecipientHelper - CDSI request successful, quota used by this request: 1
2024-06-12T03:12:20.788-0600 [pool-11-thread-1] DEBUG o.a.s.m.s.recipients.RecipientStore - Marking 0 numbers as unregistered
2024-06-12T03:12:20.788-0600 [pool-11-thread-1] DEBUG o.a.s.m.s.recipients.RecipientStore - Marking 1 numbers as discoverable
2024-06-12T03:12:20.789-0600 [pool-8-thread-1] INFO  o.asamk.signal.jsonrpc.SocketHandler - Connection 2 closed:  UnixDomainPrincipal[user=simnige1, group=simnige1]

Tsjippy avatar Jun 12 '24 09:06 Tsjippy

any clue?

Tsjippy avatar Jun 19 '24 08:06 Tsjippy

I found the issue. The problem is that socat closes the connection before signal-cli can send the response. By default socat has a timeout of 0.5s after its input stream has closed. The timeout can be increased with the -t parameter. printf '{"jsonrpc":"2.0","method":"getUserStatus","params":{"recipient":["+SOMENUMBER"]},"id":6}' | socat -t 60 UNIX-CONNECT:/home/simnige1/sockets/signal -

AsamK avatar Oct 26 '24 12:10 AsamK

Thank you so much!☺️

Tsjippy avatar Oct 26 '24 14:10 Tsjippy