Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Error connecting to JabRef" but reference is sent fine to Jabref #493

Closed
jgaztelu opened this issue Sep 26, 2022 · 17 comments · Fixed by JabRef/jabref#11047
Closed

"Error connecting to JabRef" but reference is sent fine to Jabref #493

jgaztelu opened this issue Sep 26, 2022 · 17 comments · Fixed by JabRef/jabref#11047

Comments

@jgaztelu
Copy link

Hi,

I just started using Jabref a couple of days ago and I'm seeing this issue when importing sources via the browser extension.

If I go to a website like Wikipedia or Arxiv and click on the Jabref extension, the data is sent to Jabref as I would expect and I can import it without issues, but I still get the "Error connecting to Jabref" error tab on the browser. An interesting detail is that this only happens if Jabref is already running, otherwise the extension seems to open Jabref and import the references without any issue.

Both Jabref and the extension where downloaded from the official page links, I'm not running any development version or similar.

I have tried adding the jabref-firefox.json path to the register as mentioned in the manual, but no changes.

I'm using the following versions if it helps:

  • JabRef 5.7--2022-08-05--73c111c
  • Jabref browser extension 2.5
  • Firefox 105.01-64bit
  • Powershell 7.2
  • WIndows 10 Pro 21H1 (19043.2006)
@tobiasdiez
Copy link
Member

I also had this from time to time but can no longer reproduce it (with JabRef v5.7). Can you please run the following in powershell

& 'C:\Program Files\JabRef\runtime\bin\JabRef.bat' -importToOpen "<path to a bib file>"

and then afterwards $LASTEXITCODE and $? while JabRef is running. For me this looks like
image

Moreover, once you get the error again, could you please have a look at the browser console (Ctrl + Shift + J) and the web console (Ctrl + Shift + K) and copy what you see there. Thanks!

@mai-space
Copy link

I am having a similiar error - when running your command, this is my output:

& 'C:\Program Files\JabRef\runtime\bin\JabRef.bat' -importToOpen "\\wsl$\Ubuntu-20.04\home\xxx\projects\xxxxxxxxxx\bibliography\biblio.bib"
Okt. 04, 2022 10:51:52 AM com.sun.javafx.application.PlatformImpl startup
WARNUNG: Unsupported JavaFX configuration: classes were loaded from 'module org.jabref.merged.module', isAutomatic: false, isOpen: true
2022-10-04 10:51:53 [JavaFX Application Thread] org.jabref.logic.net.ssl.TrustStoreManager.createTruststoreFileIfNotExist()
INFO: Trust store path: C:\Users\xxxxx\AppData\Local\org.jabref\JabRef\ssl\truststore.jks
Importing in unknown format: \\wsl$\Ubuntu-20.04\home\xxxxxx\projects\xxxxxxxxxxxx\bibliography\biblio.bib
Format used: BibTeX
2022-10-04 10:51:55 [JavaFX Application Thread] org.jabref.gui.JabRefMain.handleMultipleAppInstances()
INFO: Arguments passed on to running JabRef instance. Shutting down.

I do have also a problem with my surface and its network driver, so I am trying to fix this at the same time.
I will report back, if this fixes this problem too.

The error form the jabref extension is:

Error when communicating with the native messaging host.
Unknown error while sending to JabRef.
Error: Error when communicating with the native messaging host. at chrome-extension://bifehkofibaamoeaopjglfkddgkijdlh/browser-polyfill.min.js:1:6365
JabRef 5.7--2022-08-05--73c111c
Windows 10 10.0 amd64 
Java 18.0.2 
JavaFX 18.0.1+2

@tobiasdiez
Copy link
Member

Thanks! Sadly the error message doesn't contain anything helpful, except for that the Jabref script didn't respond in the way Chrome was expecting it, see https://developer.chrome.com/docs/apps/nativeMessaging/#native-messaging-debugging.

So we have to dig deeper, if you have a bit of time. Can you please locate the powershell script (its in the same folder as the jabref exe)
and uncomment the following lines
https://github.com/JabRef/jabref/blob/e48ed0c8ea3238bf6feb43421c309fd2ba1e431f/buildres/windows/JabRefHost.ps1#L42-L44 (you probably need admin rights to write to the powershell script).

If you do this and then import something from the browser extension, there should be a small popup printing exactly the same output as the command above. If there is no popup at all, please use the debug statement in the powershell script also in the catch block at the end.


If that doesn't point to anything meaningful, I have to investigate if the last point in https://developer.chrome.com/docs/apps/nativeMessaging/#native-messaging-debugging is helpful:

Windows-only: Make sure that the program's I/O mode is set to O_BINARY. By default, the I/O mode is O_TEXT, which corrupts the message format as line breaks (\n = 0A) are replaced with Windows-style line endings (\r\n = 0D 0A). The I/O mode can be set using __setmode.

@mai-space
Copy link

Okay so, before I run any scripts just a little update.
I updated some drivers and now my network problem seems to be resolved.
I can upload images again and also the jabref extension did not throw any error sofar.
BUT - it does now open in a new window of jabref :D
So I have to copy the entry to the already open bib file manuel. But not all the time. The first import of the entry did work correctly but also opend a new window afterwards.

Now I will just finish a bit of work that way and try your comment :)

Thank you for your time

@tobiasdiez
Copy link
Member

This may be the same issue: JabRef/jabref#9196

@jgaztelu
Copy link
Author

jgaztelu commented Oct 5, 2022

I also had this from time to time but can no longer reproduce it (with JabRef v5.7). Can you please run the following in powershell

& 'C:\Program Files\JabRef\runtime\bin\JabRef.bat' -importToOpen "<path to a bib file>"

and then afterwards $LASTEXITCODE and $? while JabRef is running. For me this looks like image

Moreover, once you get the error again, could you please have a look at the browser console (Ctrl + Shift + J) and the web console (Ctrl + Shift + K) and copy what you see there. Thanks!

Hi, sorry for the late answer.

I just reproduced your steps in Powershell and this is what I get:
jabref1
jabref2

Everything looks fine at first glance, the only message I don't see is the "Arguments passed to Jabref instance..." one. I don't know if that's relevant at all.

Moreover, this is what I get at the browser console:
jabref3

And this is what I see at the web console when I try to import the reference:
jabref4

Let me know if you need more info!

@tobiasdiez
Copy link
Member

Thanks!

the only message I don't see is the "Arguments passed to Jabref instance..." one. I don't know if that's relevant at all.

I think this is the culprit. The absence of this message means that JabRef cannot find the already opened instance, which leads then to the issues you observe. There are already similar issues reported at the main repo JabRef/jabref#9196. These should be fixed with the next release of JabRef and hopefully your issue disappears then as well. Sorry for the inconvenience!

@DvP17
Copy link

DvP17 commented Dec 21, 2022

The "Error connecting to JabRef" issue remains under newest version 5.8

Brave [Version 1.46.144 Chromium: 108.0.5359.128 (Official Build) (64-bit)]
JabRef 5.8--2022-12-18--b7fae4b
Windows 10
Java 18.0.2.1
JavaFX 19+11

@tobiasdiez
Copy link
Member

@DvP17 sorry for the late reply. Could you please follow the debug steps outlined at #493 (comment). That hopefully allows me to find the origin of the issue.

@DvP17
Copy link

DvP17 commented Jan 9, 2023

@tobiasdiez Thank you for your answer. I followed your instructions and it simply prints out a pop-up window with the BibTeX citation (attached). It also imports successfully, but there is still the new tab showing up in the browser with the error message:

"Error when communicating with the native messaging host. at chrome-extension://bifehkofibaamoeaopjglfkddgkijdlh/browser-polyfill.min.js:1:6365"

jabref

@tobiasdiez
Copy link
Member

tobiasdiez commented Jan 9, 2023

Okay, so this means that the correct message is passed to JabRef. That's already a good start.
Could you comment again the output line, i.e. #$output = "$messageText" and run the import again. Then the popup should show the response from JabRef.

Could you also try to replace the "return ..." line that follows by return Respond @{message="ok"; output="Test"}

@DvP17
Copy link

DvP17 commented Jan 9, 2023

So the response from JabRef looks fine, right (attached)? When I replace the return line, the same pop-up window (same message) appears.

jabref2

@tobiasdiez
Copy link
Member

Sorry @DvP17 for the late response. Thanks for testing it further. Yes, the response looks fine. So I'm lost. Just to make sure that I properly understand the issue: The reference is correctly added in JabRef, but you still get an error message in your browser, right?

@DvP17
Copy link

DvP17 commented Jan 23, 2023

No worries. Thank you for your reply!

The reference is correctly added in JabRef, but you still get an error message in your browser, right?

Yes, that is correct.

@tobiasdiez
Copy link
Member

That's strange, and I've no idea how to fix this properly. What I can offer is to add a preference option that silences all error messages. Then you don't get these false-positives, but also no notifications something "real" is broken. Would that be a solution, or do you have any other ideas how to address this issue?

@DvP17
Copy link

DvP17 commented Jan 24, 2023

Since I'm not familiar with the code, I'm not sure what might cause the error message. What triggers the error message, where is it coming from? Is the powershell script opening the respective html connection? Yes, suppressing error messages might be helpful.

@jemiryguo
Copy link

jemiryguo commented Feb 13, 2023

I fix this by modify the code in JabRefHost.ps1 line 39 and 40 into this:

    $output = & $jabRefExe -importToOpen $tempfile *>$null
    Remove-Item $tempfile *>$null

Drop all output make it works. This issue seems to caused by the unexpected output polluting the stdout, which is directly returned to sendNativeMessage call in extension.

This will make the output varible empty, i thinks it is ok, because output is send to the extension but not used at all.

Hope this will fix yours too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants