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

Creating tunnels on start #12

Closed
fieldOfView opened this issue Jul 12, 2020 · 22 comments
Closed

Creating tunnels on start #12

fieldOfView opened this issue Jul 12, 2020 · 22 comments
Labels
bug Something isn't working fixed The issue is fixed, but not yet released

Comments

@fieldOfView
Copy link
Owner

fieldOfView commented Jul 12, 2020

@inomad360 reported in #6 (comment):

Is it possible to create a tunnel when
octopi boots? I remotely turn the printer on/off. When octopi comes online,
the default seems to be no tunnel. Since I have a paid domain, I have o be
in the network o create it. Thank you.

@fieldOfView
Copy link
Owner Author

@inomad360, do you have the Create a tunnel when OctoPrint starts checkbox checked? That should create a tunnel when OctoPrint starts. If it doesn't, that is a bug that needs to be investigated.

@inomad360
Copy link

inomad360 commented Jul 12, 2020 via email

@inomad360
Copy link

I have tested and it does NOT automatically create tunnel on startup. I have unplugged the server 2x and restarted. I can confirm that I have checked the "Create a tunnel when OctoPrint starts checkbox" checked? I am on 0.2.0 and using a custom domain. The custom domain fix works great.

@fieldOfView
Copy link
Owner Author

Then I'll have to investigate why this is not working. Could you upload your octoprint.log for me? Just in case something unexpected is visible there.

@fieldOfView fieldOfView added bug Something isn't working and removed info needed labels Jul 13, 2020
@fieldOfView fieldOfView added this to Backlog in Cura Plugins via automation Jul 13, 2020
@fieldOfView fieldOfView moved this from Backlog to To do in Cura Plugins Jul 13, 2020
@inomad360
Copy link

inomad360 commented Jul 13, 2020 via email

@fieldOfView
Copy link
Owner Author

Unfortunately, attachments don't carry over via github. So you would either have to drag/drop it into a comment here in the github interface, or post a link to somewhere on dropbox, google drive or the likes.

@inomad360
Copy link

octoprint log.log

@fieldOfView fieldOfView moved this from To do to In progress in Cura Plugins Jul 14, 2020
@fieldOfView
Copy link
Owner Author

This is a strange error in your log:
2020-07-13 17:00:02,021 - pyngrok.process - ERROR - t=2020-07-13T17:00:02+0100 lvl=eror msg="failed to reconnect session" obj=csess id=996fbe31bf2a err="dial tcp: lookup tunnel.us.ngrok.com on 192.168.86.1:53: dial udp 192.168.86.1:53: connect: network is unreachable"

It looks like ngrok can't access the ngrok server because the network is unreachable when OctoPrint starts.

I am grasping at straws here, but I see that you also have the Astroprint plugin installed, and there is at least one user that says the two plugins are somehow incompatible: #5 (but I don't know how/why). Could you try disabling that plugin to see if that makes any difference?

@inomad360
Copy link

Thanks for checking the log. Uninstalled Astroprint and rebooted. Ngrok did not create a tunnel upon startup and error is there in the log . Here is what I tried:

  1. ping 192.168.86.1 - ping is OK
  2. ping tunnel.us.ngrok.com - timeout
  3. ping 3.20.27.198 - timeout
  4. ping 192.168.86.1:53 - timeout

Will further diagnose today.

octoprint.log

@inomad360
Copy link

One more data point. Ngrok is the only plugin that cannot access the internet.

image

@fieldOfView
Copy link
Owner Author

There are strange things going on in your network. From the latest log you posted:

2020-07-13 11:44:54,504 - octoprint.plugins.pluginmanager - ERROR - Could not fetch plugins from repository at https://plugins.octoprint.org/plugins.json: HTTPSConnectionPool(host='plugins.octoprint.org', port=443): Max retries exceeded with url: /plugins.json (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb0183e10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python2.7/site-packages/octoprint/plugins/pluginmanager/__init__.py", line 988, in _fetch_repository_from_url
    r = requests.get(repository_url, timeout=30)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/raven/breadcrumbs.py", line 341, in send
    resp = real_send(self, request, *args, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/home/pi/oprint/local/lib/python2.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
ConnectionError: HTTPSConnectionPool(host='plugins.octoprint.org', port=443): Max retries exceeded with url: /plugins.json (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb0183e10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
2020-07-13 11:44:55,112 - octoprint.plugins.softwareupdate - WARNING - Could not check fullscreen for updates due to a network error
2020-07-13 11:44:55,121 - octoprint.plugins.softwareupdate - WARNING - Could not check astroprint for updates due to a network error
2020-07-13 11:44:55,124 - octoprint.plugins.softwareupdate - WARNING - Could not check simpleemergencystop for updates due to a network error
2020-07-13 11:44:55,125 - octoprint.plugins.softwareupdate - WARNING - Could not check PrusaETAOverride for updates due to a network error
2020-07-13 11:44:55,129 - octoprint.plugins.softwareupdate - WARNING - Could not check octoprint for updates due to a network error
2020-07-13 11:44:55,138 - octoprint.plugins.softwareupdate - WARNING - Could not check octolapse for updates due to a network error
2020-07-13 11:44:55,141 - octoprint.plugins.softwareupdate - WARNING - Could not check ngrok for updates due to a network error
2020-07-13 11:44:55,141 - octoprint.plugins.softwareupdate - WARNING - Could not check TheSpaghettiDetective for updates due to a network error

(so not just ngrok)

@fieldOfView
Copy link
Owner Author

1. ping 192.168.86.1 - ping is OK
2. ping tunnel.us.ngrok.com - timeout
3. ping 3.20.27.198 - timeout
4. ping 192.168.86.1:53 - timeout

1 seems to be your router, which can be reached. That's good.
4: you can't ping a specific port, so this is expected not to work.
2 and 3: Well, if ngrok can't reach its servers, it cannot work. You could try the other regions (Europe for example: tunnel.eu.ngrok.com or 52.28.187.147).

I am again grasping a straw: could it be that it takes a while after booting before your Pi has a reliable connection to your wifi?

@inomad360
Copy link

I uninstalled and installed ngrok plugin, still the same error. The plug in works, but it does not connect to the custom subdomain initially on startup even when the button is checked. I am not a coder here - but how does the plugin create a tunnel after startup if it does not have access to ngrok servers?

octoprint.log

@fieldOfView
Copy link
Owner Author

how does the plugin create a tunnel after startup if it does not have access to ngrok servers?

I have no idea.

Could you try pinging tunnel.eu.ngrok.com and 52.28.187.147?

@fieldOfView
Copy link
Owner Author

This is not an isolated issue (though I still think the problem is somehow in your network/router):
https://community.octoprint.org/t/ngrok-tunnel-a-more-secure-but-simple-to-use-alternative-to-port-forwarding/21224/46?u=fieldofview

It looks like I may have to add a "retry" mechanism if the first connection to the ngrok service fails.

@inomad360
Copy link

To diagnose the issue, I have re-flashed and re-installed octoprint. Still will not login upon restart. Log attached. Thank you.

octoprint.log

@inomad360
Copy link

...also, since it connects without any issues after the reboot is complete, can there be a check to see if it is logged in with a time lag?

@fieldOfView
Copy link
Owner Author

Commit 37405be adds a retry after 20 seconds. This is in the devel branch.

@fieldOfView fieldOfView added the fixed The issue is fixed, but not yet released label Jul 27, 2020
@fieldOfView
Copy link
Owner Author

Please help testing the fix by installing the current development version via OctoPrint Settings -> Plugin Manager -> Get more -> ... from URL with the following url: https://github.com/fieldOfView/OctoPrint-ngrok/archive/devel.zip

@inomad360
Copy link

inomad360 commented Jul 27, 2020 via email

@fieldOfView
Copy link
Owner Author

Great, thanks for testing. Of course the greater issue remains to fix your network while starting, but that is beyond the scope of this plugin. Good to know it works for now.

Cura Plugins automation moved this from In progress to Done Jul 30, 2020
@inomad360
Copy link

inomad360 commented Jul 30, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed The issue is fixed, but not yet released
Projects
Cura Plugins
  
Done
Development

No branches or pull requests

2 participants