pajikos / sms-gammu-gateway

Simple SMS REST API gateway for sending SMS from gammu supported devices
Apache License 2.0
116 stars 31 forks source link

ERROR in app: Exception on /getsms [GET] #5

Closed rchovan closed 3 years ago

rchovan commented 3 years ago

Hi, nice work with this addon. I'm trying it in docker. I can successfully read signal, but /getsms show exception error:

192.168.2.5 - - [04/Sep/2020 22:24:52] "GET /signal HTTP/1.1" 500 -
[2020-09-04 22:24:52,858] ERROR in app: Exception on /getsms [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.8/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/flask_httpauth.py", line 163, in decorated
    return f(*args, **kwargs)
  File "./run.py", line 78, in get
    machine.DeleteSMS(Folder=0, Location=sms[0]['Location'])
gammu.ERR_MEMORY_NOT_AVAILABLE: {'Text': 'The type of memory is not available or has been disabled.', 'Where': 'DeleteSMS', 'Code': 81}

My docker_compose.yaml:

version: '3'
services:
  sms-gammu-gateway:
    container_name: sms-gammu-gateway
    restart: always
    image: pajikos/sms-gammu-gateway
    environment:
      - PIN=""
      - TZ=Europe/Bratislava
    network_mode: host
    ports:
      - "5000:5000"
    volumes:
      - /data/_docker/sms-gammu-gw/credentials.txt:/sms-gw/credentials.txt
    devices:
      - /dev/serial/by-id/usb-HUAWEI_Technology_HUAWEI_Mobile-if00-port0:/dev/mobile

Testing on host server outside of docker:

my device::

Bus 002 Device 012: ID 12d1:1001 Huawei Technologies Co., Ltd. E161/E169/E620/E800 HSDPA Modem

gammu -c gammu.config identify

Zariadenie           : /dev/serial/by-id/usb-HUAWEI_Technology_HUAWEI_Mobile-if00-port0
Výrobca             : Huawei
Model                : E1752 (E1752)
Firmware             : 11.126.13.00.00
IMEI                 : 359853037938320
SIM IMSI             : 231060101939374

gammu -c gammu.config getallsms

Umiestnenie 100001, zložka "Prijaté", pamäť telefónu, Doručené správy
SMS správa
SMSC číslo         : "+421903333000"
Odoslané            : Pi  4. september 2020, 22:08:30 +0200
Kódovanie           : Unicode (bez kompresie)
Vzdialené čísla   : "+421903xxxxxx"
Stav                 : Prečítané

+ľščťžýáíé=oó

Umiestnenie 100002, zložka "Prijaté", pamäť telefónu, Doručené správy
SMS správa
SMSC číslo         : "+421903333000"
Odoslané            : Pi  4. september 2020, 22:13:50 +0200
Kódovanie           : Východzia GSM abeceda (bez kompresie)
Vzdialené čísla   : "+421903xxxxxx"
Stav                 : Prečítané

Test
pajikos commented 3 years ago

Hi, have you tried to receive SMS without diacritics only? I see the first message containing special characters.

rchovan commented 3 years ago

Yes, the second message was without diacritics.

pajikos commented 3 years ago

I have the same problem, it seems the problem is related to the gammu version (https://github.com/gammu/gammu/issues/460), since 1.40 there is an error, but it seems to be fixed in the next release. So wait or try to downgrade the gammu package in your docker image to version prior 1.40 (e.g. 1.39).

pajikos commented 3 years ago

FYI, the official HOME ASSISTANT image downgraded its dependency as well.

rchovan commented 3 years ago

Ok, will try, gammu on my host, where it is working is 1.41.0-1.1 version.

Thanks.

rchovan commented 3 years ago

Could you please prepare docker image with gammu 1.39 or with fixed one version ? I have successfully upgraded gammu in docker to 1.41.0-1.1, but I got same error. So I've deleted docker image, created new one, and downgraded to 1.38.1 (1.39 is not available in debian). But with this version run.py show this errors:

ImportError: libmariadbclient.so.18: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "./run.py", line 7, in <module>
    from support import load_user_data, init_state_machine
  File "/sms-gw/support.py", line 3, in <module>
    import gammu
  File "/usr/local/lib/python3.8/site-packages/gammu/__init__.py", line 26, in <module>
    from gammu._gammu import *
pajikos commented 3 years ago

Please try to use the current image, switched to alpine and the gammu version 1.39.

rchovan commented 3 years ago

Hi, new image is working, but I see this in logs, it is error or not ?

./run.py:66: DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats
  sms = machine.GetNextSMS(Start=True, Folder=0)

Anyway thanks, and if this is not relevant, you can close this issue.