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

Failed to register: StatusCode: 429 (RegistrationRetryException)

Open Cangoo opened this issue 2 years ago • 24 comments

The problem

Get {"error":"Failed to register: StatusCode: 429 (RegistrationRetryException)\n" when trying to register number with captcha.

Are you using the latest released version?

  • [X] Yes

Have you read the troubleshooting page?

  • [X] Yes

What type of installation are you running?

signal-cli-rest-api Docker Container

In which mode are you using the docker container?

Normal Mode

What's the architecture of your host system?

arm64

Additional information

I'm trying to set up the docker container for homeassistant for a land-line number using this readme: https://github.com/bbernhard/signal-cli-rest-api/blob/master/doc/HOMEASSISTANT.md

Using this line of code: curl -X POST -H "Content-Type: application/json" --data '{"use_voice": true}' 'http://127.0.0.1:8080/v1/register/+43123456789

I get the reply: {"error":"Captcha required for verification, use --captcha CAPTCHA\nTo get the token, go to https://signalcaptchas.org/registration/generate.html\nAfter solving the captcha, right-click on the \"Open Signal\" link and copy the link.\n"}

So I go to https://signalcaptchas.org/registration/generate, solve the captcha and get a link like: signalcaptcha://signal-hcaptcha.5fad9...aEIVfjTLs4E

As descripted in the readme, I then do: curl -X POST -H "Content-Type: application/json" -d '{"captcha":"signal-hcaptcha.5fad9...aEIVfjTLs4E", "use_voice": true}' 'http://127.0.0.1:8080/v1/register/+43123456789'

But here I only get the reply: {"error":"Failed to register: StatusCode: 429 (RegistrationRetryException)\n"

I couldn't find any information about this error. The land-line number I use isn't registered for Signal yet (it's mine for over 10 years and I never tried a registration before).

Any idea what might be wrong?

Added: Since the error is "RegistrationRetryException", I tried to figure out if the number has been registered (somehow):

http://127.0.0.0:8080/v1/receive/+43123456789

results in:

{"error":"User +43123456789 is not registered.\n"}

Cangoo avatar Nov 05 '23 15:11 Cangoo

I found out that when deleting all files in /signal-cli-config/, the error "RegistrationRetryException" vanishes.

Can't check if it fully works because I get a "Rate limit exceeded"-error now. So waiting for that to vanish too...

Cangoo avatar Nov 05 '23 19:11 Cangoo

Nope, still get {"error":"Failed to register: StatusCode: 429 (RegistrationRetryException)\n". Any ideas?

Cangoo avatar Nov 06 '23 05:11 Cangoo

Got a bit of the same issue. For captcha you have to use the complete url (including signalcaptcha://), at least that worked for me. Now I'm stuck with the verification. Got the verification number via sms but I get "Verify error: StatusCode: 404" trying to verify it. I also hit the rate limit now.

A380Coding avatar Nov 06 '23 16:11 A380Coding

Hi and thanks for your reply and the hint with the signalcaptcha:// - very helpful.

I now managed to get the call for the verification number by doing this (see https://github.com/AsamK/signal-cli/wiki/Quickstart#set-up-an-account):

curl -X POST -H "Content-Type: application/json" --data '{"use_voice": false, "captcha":"signalcaptcha://signal-hcaptcha.5fad...Rk--Ro"}' 'http://127.0.0.1:8080/v1/register/+43123456789'

WAIT 60 sec

curl -X POST -H "Content-Type: application/json" --data '{"use_voice": true, "captcha":"signalcaptcha://signal-hcaptcha.5fad...YmYTv56fA"}' 'http://127.0.0.1:8080/v1/register/+43123456789'

The link above claims that Failed to register: [429] Rate limit exceeded: 429 (RateLimitException) might be an error if you are not doing this correctly (first use voice=false, then wait, then voice=true).

But now I'm stuck at the same point as you: curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+43123456789/verify/123-456' => {"error":"Verify error: StatusCode: 404\n"}

Do you now if the format for the code is '123-456' or '123456'? Okay, both didn't work...

Cangoo avatar Nov 06 '23 19:11 Cangoo

Uh, oh, eh, although I got the verification-error, I'm now able to send messages. Yay!

Cangoo avatar Nov 06 '23 19:11 Cangoo

What did you change to verify?

A380Coding avatar Nov 06 '23 19:11 A380Coding

Not sure what did the trick. I tried:

curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+43123456789/verify/123-456'

and

curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+43123456789/verify/123456'

several times, I even called: http://127.0.0.1:8080/v1/register/+43123456789/verify/123-456 in the browser, always getting "Verify error: StatusCode: 404". I then out of fun tried to receive messages which suddenly worked.

Added: I tried to receive in browser by calling: http://127.0.0.1:8080/v1/receive/+43123456789 and got an empty array [ ] back.

Cangoo avatar Nov 06 '23 19:11 Cangoo

Hey, got it working by waiting 60 seconds before setting use_voice to true too. I also removed the hyphen in the registration code in the verify URL.

mwllgr avatar Nov 06 '23 21:11 mwllgr

Hello, I just tried it with another landline-number and it worked like charm on the first try using no hyphen in the code to verify the number.

Cangoo avatar Nov 07 '23 06:11 Cangoo

Does not work for me. Verifying results in "StatusCode: 404"

flocsi avatar Nov 26 '23 10:11 flocsi

please try with Version 0.80

bbernhard avatar Dec 20 '23 20:12 bbernhard

Even with V 0.80, I receive "Verify error: StatusCode: 404" after entering the code I received via phone call.

flocsi avatar Dec 28 '23 13:12 flocsi

I found that I was getting 429 when I specified use_voice to true initially. It seems that you just set use_voice to false, make a request, then set use_voice to true. And only provide it a captcha after getting an error stating it is required. I also found that on my second attempt after setting use_voice to true, it required another request with the same payload to give me a successful response.

For me, the following worked:

  1. use_voice false without captcha
  2. use_voice false with captcha
  3. use_voice true without captcha ---> 429
  4. use_voice true without captcha ---> 201

alexyao2015 avatar Mar 10 '24 04:03 alexyao2015

I get "StatusCode: 502 (ExternalServiceFailureException)". Perhaps, it is an issue with this particular landline number that has been used earlier.

flocsi avatar Mar 15 '24 15:03 flocsi

Running on the machine running the signal-cli-rest-api I have tried the following:

curl -X POST -H "Content-Type: application/json" --data "{\"use_voice\": false}" 'http://10.0.0.44:8080/v1/register/+14807751111' which gives the '{"error":"Captcha required for verification, '

I then generate a captcha on my laptop and try

url -X POST -H "Content-Type: application/json" --data "{\"use_voice\": false, \"captcha\":\"signalcaptcha://s ignal-hcaptcha.5fad97ac-7d06-4e44-b18a- ... "}" 'http://1 0.0.0.44:8080/v1/register/+14807751111'

which gives '{"error":"Invalid captcha given.\n"}'

If I try the same command again, it gives '{"error":"Failed to register: StatusCode: 429 (RegistrationRetryException)\n"'

Does the captcha need to be generated on the same machine that the rest api is running on? (If so, how does one do that running HA on a Raspberry Pi?) And then the 429 is generated because of retrying too quickly?

PeterNSteinmetz avatar Sep 13 '24 02:09 PeterNSteinmetz

The actual machine doesn't matter. But you need to be fast, as those captcha tokens are really short-lived.

What also helps is to back off a bit (especially if you tried it often in a short period of time) and try it again in a few hours. Sometimes artifacts from an unsucessful registration attempt are left beft behind, so you could also try to remove all the data in the signal-cli-config folder on your disk before retrying

bbernhard avatar Sep 13 '24 04:09 bbernhard

Thanks. So the first request should be with use_voice false and with a captcha? Then the second request after 60 seconds with use_voice=true should also have a captcha which is different?

How would I remove those files when the server is running inside the docker container?

PeterNSteinmetz avatar Sep 13 '24 04:09 PeterNSteinmetz

Thanks. So the first request should be with use_voice false and with a captcha? Then the second request after 60 seconds with use_voice=true should also have a captcha which is different?

How would I remove those files when the server is running inside the docker container?

I never needed to do the dance that some people needed to do in order to get a number registered. I think the Signal Server has good days and bad days and on those bad days the registration just doesn't work (I guess they have some sort of abuse protection in place, which might accidentally trigger).

So, ideally it should just work, no matter if you use use_voice or not. As already mentioned, the captcha token that is returned is really short lived, so you need to be fast.

How would I remove those files when the server is running inside the docker container?

Did you bind mount the folder from the host system to the docker container? If so, just remove the all the files inside and restart the container.

If you instead use docker volumes, you can find the docker container id of the running docker container with docker ps and then connect to the running docker container with docker exec -it <container id> /bin/bash. Inside the docker container remove everything inside the /home/.local/share/signal-cli/ folder. Afterwards, restart the docker container and try again.

bbernhard avatar Sep 13 '24 18:09 bbernhard

@bbernhard Thanks again for the suggestions and your work on this rest API.

I am running this under HomeAssistant so using the docker container at ghcr.io/haberda/signal_messenger/aarch64:0.88.0 . By stopping the add-on in HA the docker container went away and then starting it again presumably cleared the configurations files.

The following then worked for me:

curl -X POST -H "Content-Type: application/json" --data '{"use_voice": false, "captcha":"signalcaptcha://signal-hcaptcha.5fad97ac-7d06-4e44-b18a- ... "}' 'http://10.0.0.44:8080/v1/register/+14807751111'

Wait one minute.

curl -X POST -H "Content-Type: application/json" --data '{"use_voice": true}' 'http://10.0.0.44:8080/v1/register/+14807751111'

That phone number then rang and it gave me the verification code by voice.

curl -X POST -H "Content-Type: application/json" 'http://10.0.0.44:8080/v1/register/+14807751111/verify/123456'

I was then able to send a message with curl -X POST -H "Content-Type: application/json" --data '{"message":"Test from HA.","number":"+14807751111","recipients":["+14808622222"]}' 'http://10.0.0.44:8080/v2/send'

None of these commands returned an error code or output. The captcha itself was simply generated on another machine that has the same external ip as the machine running homeassistant.

I pre-composed the commands in a text editor so I could rapidly copy the captcha link into the command and then execute it.

PeterNSteinmetz avatar Sep 14 '24 02:09 PeterNSteinmetz