Closed DandyMountainLion closed 5 months ago
your URL is fine, I'd be curious to know what the error is you getwhen you're trying to add a note while the wifi is on
As to your other issue, I'm a bit confused by the log
03/20/24-18:23:37 ERROR Failed to initialize anki plugin: plugins/anki.koplugin/ankiconnect.lua:277: attempt to index local 'note' (a nil value)
One of the notes that are stored locally in anki.koplugin_notes.json
must be corrupted. Looking at your screenshot it seems fine to me at first glance, it doesn't really matter whether "params" or "version" is listed first, as long as they're both present. The fact that note
is nil means one of them must be invalid JSON, hard for me to tell which one unless you post the file, you could try and remove them one after another until it works :smile:
I don't get how you first run into that 'attempt to index local 'note'' issue, but then still manage to create a note at some later point. If the button disappeared, how were you able to add a note?
./luajit: plugins/anki.koplugin/ankinote.lua:45: attempt to index field 'document' (a nil value)
This happened while it was trying to get the metadata for whatever document you were reading, somehow this document wasn't present. This is initialized by KOreader itself, so I can't really tell why it might've been missing for you there
Thanks for the fast reply ! 😄
I don't get how you first run into that 'attempt to index local 'note'' issue, but then still manage to create a note at some later point. If the button disappeared, how were you able to add a note?
The weird thing is that I wasn't getting any errors while adding the cards and the button only disappeared after the crash when Koreader restarted
I'd be curious to know what the error is you getwhen you're trying to add a note while the wifi is on
To be able have the button back and to screenshot the error, I had to clear the anki.koplugin_notes.json
file so I have joined it before the clear, in case you are still curious about it (I made a copy in case the issue is fixed and the cards can be salvaged but if it's not possible that's also okay)
anki.koplugin_notes.json
Here is the screenshot of the error when the Wifi is on:
If I understood correctly it comes from an error due to misconfiguration of IP/port ?
Here is my AnkiConnect config:
{
"apiKey": null,
"apiLogPath": null,
"ignoreOriginList": [],
"webBindAddress": "0.0.0.0",
"webBindPort": 8765,
"webCorsOriginList": [
"http://localhost"
]
}
What I tried:
The curl method
But for some reason the curl command is not installed? Even though the terminal can wget/ps without a problem. It's the default sh terminal, should I try an other? If so which one?
The ping command It's not a network problem since the ereader can ping 1.1.1.1, it can also ping the gateway but it cannot ping the IPv4 address PC can ping the ereader
Network I went into my PC firewall setting and allowed anki to be accessed though private networks
To be able have the button back and to screenshot the error, I had to clear the
anki.koplugin_notes.json
file so I have joined it before the clear, in case you are still curious about it (I made a copy in case the issue is fixed and the cards can be salvaged but if it's not possible that's also okay)
On line 4 you have 2 JSON strings on a single line, that's the one it's failing on, this should just be:
{"version":6,"action":"addNote","params":{"note":{"options":{"duplicateScope":"deck","allowDuplicate":false},"tags":["KOReader"],"deckName":"日本語","_field_callbacks":{"audio":{"args":["掃除","ja"],"func":"set_forvo_audio"},"picture":{"args":{},"func":"set_image_data"}},"fields":{"Sentence":"<b>掃除</b>機がかけられないので、困ります) と立ち話をしていたりするが、最初はなに言ってんだかよく聞き取れなかった。","Definitions":"<div class=\"definition\"><ol><li dict=\"スーパー大辞林 3.0\">そう じ (さうぢ) [0]【掃除】<br>(名)スル<br>①掃いたりふいたりして,ごみや汚れをなくしてきれいにすること。「部屋を―する」「―機」<br>②害悪を除き去ること。「悪の温床を―する」<br>③便所の糞尿を汲み取ること。</li></ol></div>","Notes":"三浦しをん - 神去なあなあ日常 (6/362)","Expression":"掃除"},"modelName":"Word card Japanese"}}}
{"params":{"note":{"_field_callbacks":{"picture":{"func":"set_image_data","args":{}},"audio":{"func":"set_forvo_audio","args":["俗信","ja"]}},"deckName":"日本語","options":{"allowDuplicate":false,"duplicateScope":"deck"},"modelName":"Word card Japanese","tags":["KOReader"],"fields":{"Notes":"三浦しをん - 神去なあなあ日常 (7/362)","Expression":"俗信","Sentence":"俗信","Definitions":"<div class=\"definition\"><ol><li dict=\"スーパー大辞林 3.0\">ぞく しん [0]【俗信】<br>日常生活を左右するものとして,世間で広く信じられてきた言い伝えや迷信。禁忌・予兆・占卜(せんぼく)・呪術・諺(ことわざ)・憑(つ)き物・妖怪など。「病気についての―」</li></ol></div>"}}},"action":"addNote","version":6}
Just curious, did you use the 'delete latest note' option at any point while creating these notes? I think there might be a bug there for offline stored notes
As for your connection issue:
your anki-connect config looks fine, if you can't use curl
then just use wget
, that should work just as well.
The fact that you can't ping the IPv4 address is weird, that really should work. If you can't ping nor wget http://<IP>:8765
then it's not gonna work in the plugin either.
The fact you're getting a timeout and not a 'connection refused' makes me suspect you're using the wrong IP, and it's not a firewall issue
I managed to reproduce the issue with the 2 notes ending up on 1 line and I've pushed a fix
I managed to reproduce the issue with the 2 notes ending up on 1 line and I've pushed a fix
That's great news! I probably did try the delete button like you said.
your anki-connect config looks fine, if you can't use curl then just use wget, that should work just as well. The fact that you can't ping the IPv4 address is weird, that really should work.
Following that idea I tried to change network to make sure the ereader was exactely on the same network as my PC and I got this error (which I remember also getting before)
Still curious that the ping 1.1.1.1 still worked then.
I even though I installed KoReader with the OCP-KOReader-v2024.03.1.zip
folder and script so that might be the problem...I know it's going outside of the plugin scope but in case someone has the same error, I feel it's still appropriate to post it.
I'm trying to reinstall Koreader as of now. (Do you have the same version/did you also installed it with the OPC mechanism?)
Yeah that's definitely out of scope here, I have no idea what could be wrong. I'm currently still on v2023.04. I did find this comment which sounds similar to what you're having, and it's fixed by not using that OCP install method.
I used the linux script linked in this post to install from the zip specific for my device, which I got straight from the koreader releases on github
There's also a comment saying just turning the reader off and on again fixes it, classic :smile:
There's also a comment saying just turning the reader off and on again fixes it, classic 😄 Ah yes, the magical solution that works 8 times out of 10 haha
Sadly, that didn't work but since this isn't linked to the plugin and the one line two cards bug is fixed I should close this issue!
Thank you very much your help. 😄
Hello, first of all thank you for the plugin, it looks fantastic!
Second, here is the problem: My ereader had the wifi off and I was adding a bunch of cards offline (as I have not yet successed in connecting the ereader with Anki) when all of a sudden Koreader crashed. I did not manage to get a picture before the error disappeared but I noticed that the plugin was not working anymore (the Add to Anki button had disappeared).
But here is what the crash.log file says (Huge wall of text)
After seeing the "attempt to index local 'note' (a nil value)' error, I also looked at the
So I guess a short term answer would be to clear the file but the problem remains.
anki.koplugin_notes.json
file and there is two notes with a different format:I think there may be an error in the
I wrote the url variable like this: url = "http://IPv4:8765" (IPv4 being my IP address of course.)
Maybe it is the space in "Word Audio" ?
config.lua file
since I also can't connect but I don't seem to find it.If you have any idea that would be great, thank you!