Signal Binding [4.3.0.0;5.0.0.0)

Hello Gwendal,

I have installed the Signal Binding for the first time and I configured everything according to the instructions. Everything seems fine, but there are problems sending and receiving messages.

Error message while receiving a message:
[gnal.internal.protocol.SignalService] - Signal get an exception while receiving message: org.signal.libsignal.protocol.InvalidKeyIdException: No such signed pre key record:

Error message while sending a message:
[gnal.internal.protocol.SignalService] - Cannot send message to +49151xxxxxxx, cause network

I did a bit of googling and found at least some information to the receiving error described here: https://github.com/AsamK/signal-cli/issues/1450

signal-cli was fixed and version 0.13.0 is available since a few days: https://github.com/AsamK/signal-cli/blob/master/CHANGELOG.md

The signal-cli used by Signal Binding is 0.12.7. When will the current signal-cli version be included in the signal binding?

Regards
Ralf

Hello,

I have updated the binding to the new version 0.13, with tears and blood.
Why “tears and blood” ? Because signal-cli 0.13 is coded for java 21
 And openHAB for java 17 ! Looks like I’m back to my old friend, the backport maintenance mode :sweat_smile:

Let me know if it resolves your issues.

1 Like

Hello Gwendal,

everything works perfect now !!!
Thank you very much for your tears and blood and the mega-fast update.

Best regards,
Ralf

Dear community,

I finally have convinced myself that I need help from the forum :wink:

I have trouble understanding on how the registration should work with the binding.
Could you point me somewhere where there is something like a step by step guide?

My setup at the moment ist openHAB 4.1.2 running on a Xen virtualized Ubuntu 22.04.4 LTS.
I have made it through the various pitfalls (finding the right captcha generator, sms, wait one minute, voice
) to register one of my German landline numbers wie the command line version → signal cli

However, when trying to generate the signal account thing, I end up with the error

CONFIGURATION_PENDING
Incomplete registration: CAPTCHA_NEEDED 

When I have entered the information upon thing creation, my code looks like this:

UID: signal:signalaccountbridge:13545dd3f1
label: Signal Account
thingTypeUID: signal:signalaccountbridge
configuration:
  verificationCodeMethod: TextMessage
  phoneNumber: "+4930555123123" (made up :upside_down_face:)
  captcha: signalcaptcha://signal-hcaptcha.5f..blablacaptchagoesonforever
  deviceName: rnet-signal
  verificationCode: ""
channels:
  - id: receivetrigger
    channelTypeUID: signal:signalreceivetrigger
    label: Message Received
    description: Triggered when a message is received, in the form "<sender>|<text>"
    configuration: {}

Of course I do not know the verification code before I got the call.

Do I also need the “Text Message First, Wait 1 Minute, Voice Call request”-strategy that I needed to perform with signal-cli?

I have the feeling I am missing something simple :frowning:

Hello and welcome,

First, I’m not really sure of what you did and what you think you need ? :sweat_smile:
You write about signal-cli. Just to be clear : did you use it, for test purpose, or did you think you need it for this binding ?
To be sure : this binding use the signal cli code internally, but is a stand alone (In fact, the binding and signal-cli cannot even work at the same time)

The documentation has a (very little) step by step. But I agree it can probably be better (I’m open for proposition).

The error message means that you captcha is either invalid or expired.
They are short lived, so if you generate it during your test with signal-cli, it probably won’t be valid anymore.
They are only used during registration, so their short live is normally not an issue.

What you maybe miss is that it is a several step registration process, and so it needs your input. You need to edit and save your thing at least two times with the added information during your progress.
1- get a valid captcha (again, it is short lived, so get a fresh one)
2- Save your thing a first time, with the captcha inside. The binding will use your captcha to ask for a registration code.
(You are at this step : the captcha is not OK.)
If it’s OK, the thing will be in another state (don’t remember, maybe “verification code needed”, or something like that ?)
Anyway, next : If you choose a vocal validation, You don’t need the "Text Message First, Wait 1 Minute, Voice Call request”-strategy because it is already hard-coded in the binding. The binding will ask for a SMS, wait one minute, and ask for a vocal confirmation code. So be patient.
3- Once you have the verification code, edit your thing again to add it and save.

Now everything should be OK.
UNLESS
 Several common pitfall are:

  • signal change their API (and sometimes, error messages may be wrong)
  • temporary error with signal server
  • Last pitfall : I never used the file configuration method (I used the GUI), and I don’t know if someone on this thread had. But it shouldn’t be any different.

Hi Gwendal,

thanks a lot for answering!

So what I „need“ (i.e. want) is to use the signal binding with my landline number :wink:

I followed the signal-cli test only to make sure that in principle everything works and because I thought it would be easier to troubleshot in case of errors.

Is there a way to find out which captcha generator is the valid one without generating rate limitation issues?

At the moment I go to
https://signalcaptchas.org/registration/generate
or
https://signalcaptchas.org/challenge/generate.html

I will try to write down step by step what I am doing


At the moment I do get a ExternalServiceFailureException - StatusCode: 502
Maybe I have stressed my luck for the day

I always used the one I put in the documentation (Signal)

But you now have an ExternalServiceFailureException 502. It may relate to anything
1- temporary error from signal
2- rate limitation
3- api mismatch or deeper issue

1 or 2 requires to wait and retry (maybe tomorrow ?)
I will investigate the 3 if it still don’t work tomorrow.

I made it!! :slight_smile:

Here the steps I took in some form of detail.
Everything is already in the manual
 some of it is probably not necessary

  1. wait for 24h of doing nothing (trying to start from scratch and avoind errors due to blacklisting)
  2. delete signal account thing
  3. restart openhab
  4. Things → + → Signal Binding (marketplace:138795) → Signal Account
  5. New Signal Account configuration
  • enter a made up device name
  • enter (landline) phone number in international configuration
 +4930
.
  • select phone call
  • leave verification code empty
  1. open up new tab to get captcha
  • Signal
  • select „I am a human“
  • click through images
  • decline popup to open signal link with app
  • right click link „open signal“ → „copy link adress“
  1. back to new signal account configuration
  • paste full captcha link without further editing in „Captcha“
  • someting like signalcaptcha://signal-hcaptcha.5fad97ac-7d06-4e44-b18

  • click create thing (less than 1 minute for 4-6)
  1. back in the things overview page
  • watching the new thing going to initialize
  • wait for 1 minute
  1. take call and note verification code
  2. edit signal account thing
  • put in verification code
  • save
  • disable
  • enable
  1. watch signal thing status turn green in thing overview

Thanks for the help

I will start using in the next days

2 Likes

I also encountered a strange error when trying to fire up the thing the first time with the verification code entered.

It stayed Initilizing forever:


2024-03-26 07:03:09.917 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.nio.channels.OverlappingFileLockException: null
        at sun.nio.ch.FileLockTable.checkList(FileLockTable.java:229) ~[?:?]
        at sun.nio.ch.FileLockTable.add(FileLockTable.java:123) ~[?:?]
        at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1321) ~[?:?]
        at java.nio.channels.FileChannel.tryLock(FileChannel.java:1191) ~[?:?]
        at org.asamk.signal.manager.storage.SignalAccount.openFileChannel(SignalAccount.java:993) ~[?:?]
        at org.asamk.signal.manager.storage.SignalAccount.load(SignalAccount.java:193) ~[?:?]
        at org.asamk.signal.manager.SignalAccountFiles.initManager(SignalAccountFiles.java:97) ~[?:?]
        at org.asamk.signal.manager.SignalAccountFiles.initManager(SignalAccountFiles.java:84) ~[?:?]
        at org.openhab.binding.signal.internal.protocol.SignalService.start(SignalService.java:148) ~[?:?]
        at org.openhab.binding.signal.internal.handler.SignalBridgeHandler.checkAndStartServiceIfNeeded(SignalBridgeHandler.java:162) ~[?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
        at java.lang.Thread.run(Thread.java:840) [?:?]

Stop & Start solved the issue

The last step is missing
 Just write with your smartphone zu the new created signal account
 a new thing will be created automatically. Just create it. That’s it


having some trouble:

openHAB 3.4.4

I installed the binding from market place. But it does not show up on the Things page, add new Thing.

Digging a bit i found this in the logs

2024/04/05 16:28:53,stderr,"Caused by: org.apache.felix.resolver.reason.ReasonException: Unable to resolve marketplace-openhab-binding-signal/4.2.0.SNAPSHOT: missing requirement [marketplace-openhab-binding-signal/4.2.0.SNAPSHOT] osgi.identity; osgi.identity=org.openhab.binding.signal; type=osgi.bundle; version=\"[4.2.0.202402240118,4.2.0.202402240118]\"; resolution:=mandatory [caused by: Unable to resolve org.openhab.binding.signal/4.2.0.202402240118: missing requirement [org.openhab.binding.signal/4.2.0.202402240118] osgi.extender; filter:=\"(&(osgi.extender=osgi.component)(version>=1.5.0)(!(version>=2.0.0)))\"]

I don’t understand what it tries to tell me 


Hello,

I will add a compatibilty note in the open post.

You can also edit the post title and add something like: " [4.0.0.0;5.0.0.0)". This should filter it so that 3.x users will not see the binding in Add-on Store.

2 Likes

Hi Gwendal,
thanks for this nice work. I was really surprised on how well it worked – after some tweaks.

I am running OpenHAB on OpenWRT, this is a musl based distribution, hence your bundled libsignal_jni.so cannot work (depends on glibc).
I have first used a statically build object file (github_com/signalapp/libsignal/issues/526), but then exquo has created a build configuration for musl and the resulting object works well (Build configuration for Linux/AMD64/musl, i.e. OpenWRT, Alpine Linux · Issue #19 · exquo/signal-libs-build · GitHub).
The only hack remaining is that I need to manually swap the shared objects in userdata after the binding unpacks them.
Would it be possible for you to add detection logic for Linux/musl (e.g. detect musl by checking /proc/self/map_files by gotson · Pull Request #675 · xerial/sqlite-jdbc · GitHub) and bundle the musl library built by exquo as well?

Keep up the excellent work!
Cheers,
K

Hello,
Thanks for your praise !

I saw your comment last month in the issue 526 but didn’t quite get it :sweat_smile:
Native library, linking, etc, is not a domain I know. So, maybe I can help, but we will have to work together.

I don’t know why, but loading native library in Java is not as simple as “load(library-path)”.
Especially in an OSGi env, where we have to take additional step.
It’s the signal library that loads the native code library, by calling a system method with a lib name. The classloader, AFAIK, is then responsible to provide the library file from the name. So OSGi classloader enters here.
To choose the library to load, depending on the arch / os, OSGi provides some filter that we have to add on the bundle manifest. Creating a bundle manifest is tricky, and in our case it is automatically build.
So, to add the information to the bundle manifest, we have to add a package-info file. In this package-info file, you can see the path to the library with some conditional filter to help selecting the right one.

It means that we have to provide a filter triggered for the musl build. By looking the documentation, It doesn’t seem straightforward.
Maybe we can use the selection-filter ? I saw somewhere that environment variable can be used in the selection filter (but I’m not totally sure). I can build a test version addon including the musl library if you provide me with a selection filter to put here.

Hi Gwendal,
I managed to avoid looking at OSGi so far and don’t have that long weekend to go into it. Looking at the documentation it is indeed a selection-filter that needs to be used. I suggest to invent a global system property like org.osgi.framework.os.libc and test that against musl.
From my reading of the spec, you would need to duplicate your Linux/amd64 entries and list the one testing against musl lexically first (left) from the one not testing against this property. This way all of your users continue to get the standard glibc linked shared object. For the few of us running musl, we would define that global property at startup and get the musl version.
I have briefly looked at autodetection, but it is not straightforward. e.g. the code that I have linked earlier is NOT working in my environment.
I have also looked at my system:property within openHAB and there is no property that could be re-used to detect the environment.
On the long run, OSGi framework should be way more specific in detecting its runtime environment and set more properties like the one I am proposing. If you have pointers to them, you should drop this in as a proposal.

I don’t have a build environment to test all of this, but you can test yourself by applying the change and not setting the property (everything will work out just fine), then setting the property (loading libsignal_jni will throw an Exception due to the unsatisied dependency to musl).

Except for musl/glibc you may as well already implement static as a third valid object, in anticipation that exquo will resolve his build issue with static libraries. Static could be the new default candidate and on the long run replace both the musl/glibc objects. This is a particularly big object (6M!!) so the 500k overhead of the static linkage is negligible.

Sorry that I cannot be of more help, OSGi does not look like the beast that you want to tame over a coffee break.

If there is anything I can test, please drop it and I will try my best.

Cheers,
K

Hello,

I’m OK to try to generate a version with the musl library from exquo included, but I can’t do it now, because signal-cli still uses libsignal_v0.44.0, and there is no musl version (there is only one for 0.45).

So:

  • we can wait for signal-cli to use libsignal 0.45.
  • or If you build a libsignal 0.44 and provide it to me, I will include it in a test version.

If I understand it, a static lib will have no dependancy toward glibc or musl, and thus can be used for all linux x86_64 without additional modification and without the need to filter with arch or env param ? And the cost is it’s a little bigger ?
If it’s that, then it’s good news and I’m OK :+1:

Hi Gwendal,
thanks for the details. exquo by default runs against the newest version. I have cloned his repo and ran it now against v0.44.0.
The artifacts are at https://github.com/kevemueller/signal-libs-build/releases/tag/libsignal_v0.44.0. I have only built the linux libs.
I am not planning to keep this clone any further than strictly needed, this shall not be an authoritative source for these artifacts. Once the tests are successful, we can ask exquo to run his official build against v0.44.0.

Cheers,

Here is a test release for you.

The modification for the filter is here.
As you suggest, I use the selection-filter “org.osgi.framework.os.libc” with “musl” value.
I didn’t test to select the musl version to see if it fails, but at least I can say that the glibc version is still OK.
I hope an environment variable is sufficient for you to force the selection of the musl version.