bbernhard / signal-cli-rest-api

Dockerized Signal Messenger REST API
https://bbernhard.github.io/signal-cli-rest-api/
MIT License
1.3k stars 154 forks source link

Failed to register: StatusCode: 429 (RegistrationRetryException) #441

Open Cangoo opened 11 months ago

Cangoo commented 11 months ago

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?

Have you read the troubleshooting page?

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 commented 11 months ago

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 commented 11 months ago

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

A380Coding commented 11 months ago

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.

Cangoo commented 11 months ago

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 commented 11 months ago

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

A380Coding commented 11 months ago

What did you change to verify?

Cangoo commented 11 months ago

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.

mwllgr commented 11 months ago

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.

Cangoo commented 11 months ago

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.

flocsi commented 10 months ago

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

bbernhard commented 9 months ago

please try with Version 0.80

flocsi commented 9 months ago

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

alexyao2015 commented 6 months ago

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
flocsi commented 6 months ago

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

PeterNSteinmetz commented 2 weeks ago

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?

bbernhard commented 2 weeks ago

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

PeterNSteinmetz commented 2 weeks ago

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?

bbernhard commented 2 weeks ago

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.

PeterNSteinmetz commented 2 weeks ago

@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.