Ajatt-Tools / anki.koplugin

KOReader plugin enabling Anki card generations for words looked up in the internal dictionary.
49 stars 6 forks source link

Anki Connect invalid host 'nil' #31

Closed 1ynn1ei closed 1 month ago

1ynn1ei commented 1 month ago

Describe the Issue Setup everything, i have AnkiConnect bound to 0.0.0.0 as reinforced by lsof:

emacs   1433 lynn  18u  IPv4 917636      0t0  TCP 127.0.0.1:8080 (LISTEN)
anki    9316 lynn  18u  IPv4 915375      0t0  TCP 127.0.0.1:36099 (LISTEN)
anki    9316 lynn  52u  IPv4 923083      0t0  TCP *:8765 (LISTEN)

used ip a to get my ipv4 IP, set that up in KOReader as http://[ip]:8765. Any time I try to add a card, i will get the message that host is 'nil'. I'm not sure if that means the Hostname is not being saved properly, or if that's the object it's trying to bind and it is failing.

crash.log crash.log

07-17 16:50:37.746 I/KOReader( 8074): Loading plugins from directory: /storage/emulated/0/koreader/plugins/
07-17 16:50:37.759 V/KOReader( 8074): Loaded 4 notes from disk.
07-17 16:50:37.762 V/KOReader( 8074): RD loaded plugin anki at /storage/emulated/0/koreader/plugins//anki.koplugin
--
07-17 16:50:37.968 V/KOReader( 8074): CreDocument: goto xpointer /body/DocFragment[14]/body/div/p[23]/text().312
07-17 16:50:37.971 V/KOReader( 8074): DocSettings: data is read from /storage/9C33-6BBD/Books/Deutsch/SAO/SAO 06.sdr/metadata.epub.lua
07-17 16:50:37.976 I/KOReader( 8074): AnkiWidget:extend_doc_settings# /storage/9C33-6BBD/Books/Deutsch/SAO/SAO 06.epub {
--
07-17 16:50:49.832 I/KOReader( 8074): (re)initializing context buffer with size: 50
07-17 16:50:49.841 I/KOReader( 8074): after reinit: prev table = 329, next table = 325
07-17 16:50:49.842 I/KOReader( 8074): AnkiNote#get_custom_context() 1 0 1 0
07-17 16:50:49.843 V/KOReader( 8074): AnkiConnect#is_running = code: invalid host 'nil', headers: nil, result: nil
07-17 16:50:49.843 I/KOReader( 8074): Displaying popup with message: 'Unable to reach AnkiConnect.
--
07-17 16:51:15.740 V/KOReader( 8074): _refresh: Enqueued fast update for region 72 646 1119 87 dithering: false
07-17 16:51:15.740 V/KOReader( 8074): setDirty fast from widget nil w/ region 72 646 1119 87 dithering: nil
07-17 16:51:15.741 V/KOReader( 8074): AnkiConnect#is_running = code: invalid host 'nil', headers: nil, result: nil
07-17 16:51:15.741 I/KOReader( 8074): Displaying popup with message: 'Synchronizing failed!
07-17 16:51:15.741 I/KOReader( 8074): Unable to reach AnkiConnect.

this time i remembered the -i flag.

nairyosangha commented 1 month ago

These android ereaders usually have a browser right? Can you double check if you go to http://[ip]:8765 that it prints the AnkiConnect v.6 string?

Assuming that's okay, the response is still weird, it looks like it's not picking up the URL you set

AnkiConnect#is_running = code: invalid host 'nil', headers: nil, result: nil

This is coming from that luasocket lib KOreader is using, I can reproduce it if I make my URL something obviously wrong like http://:8765 Can you check that there's nothing weird in ./settings/ankiconnect.lua either?

1ynn1ei commented 1 month ago

This is coming from that luasocket lib KOreader is using, I can reproduce it if I make my URL something obviously wrong like http://:8765

this was exactly the issue, the screen is finnicky and i accidentally deleted a forward slash. I apologize for the waste of time. Everything seems fine now :) Thank you for the amazing plugin.