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

console script does not work when Piwik has no internet access #8253

Closed
Fensterbank opened this issue Jun 30, 2015 · 7 comments
Closed

console script does not work when Piwik has no internet access #8253

Fensterbank opened this issue Jun 30, 2015 · 7 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@Fensterbank
Copy link
Contributor

I have a piwik installation in a corporate intranet behind a proxy.
We could not get the internet connection (e.g. version check) for Piwik work.

curl_exec: Received HTTP code 405 from proxy after CONNECT.

I want to trigger the auto archiving via scheduled task, because scheduled reports are not sent automatically, but unfortunately the Piwik console needs to have a internet connection.

INFO Piwik\Access[2015-06-30 07:29:33] [46f82] ---------------------------
INFO Piwik\Access[2015-06-30 07:29:33] [46f82] INIT
INFO Piwik\Access[2015-06-30 07:29:33] [46f82] Piwik is installed at: https://piwik.abcdefghi.com/index.php
INFO Piwik\Access[2015-06-30 07:29:33] [46f82] Running Piwik 2.13.0 as Super User
ERROR Piwik\Access[2015-06-30 07:29:33] [46f82] The Piwik URL https://piwik.abcdefghi.com/index.php does not seem to be pointing to a Piwik server. Response was 'Got invalid response from API request: https://piwik.abcdefghi.com/index.php?module=API&method=API.getDefaultMetricTranslations&format=original&serialize=1&trigger=archivephp. Response was 'curl_exec: Received HTTP code 405 from proxy after CONNECT. Hostname requested was: piwik.abcdefghi.com''.

a test script with following content does work without problems from the servers command line, so normally Piwik shoud reach itself over https...

$homepage = file_get_contents('https://piwik.abcdefghi.com');
echo $homepage;

I do not understand why it is necessary for the auto archive script to open an internet connection via curl_exec.
Wouldn't it be better to handle server side scripts on the server without HTTP API calls?

@gaumondp
Copy link

Did you tried settings mentioned here #6324 ?

enable_marketplace = 0
enable_auto_update = 0
enable_update_communication = 0

@diosmosis
Copy link
Member

If the command is using HTTP requests to archive, it means the system you're using doesn't support archiving through new PHP processes. This can be because you're using windows, because the shell_exec function is disabled, the ps or awk programs do not exist or for several other reasons. In any case, the core:archive command needs to send HTTP requests for your setup.

If you are running the command on Piwik server itself, you could try supplying --url=http://localhost to the core:archive command. Let me know if this works for you, as this may not be possible in 2.14. In this case, I'll make sure it's possible in 2.14.1.

@Fensterbank
Copy link
Contributor Author

I tried it, but unfortunateley it doesn't work.

C:\Users\admin>"C:\Program Files (x86)\PHP\v5.6\php.exe" "E:\inetpub\piwik\console" core:archive --url=http://localhost/
INFO [2015-07-01 07:02:15] ---------------------------
INFO [2015-07-01 07:02:15] INIT
INFO [2015-07-01 07:02:15] Piwik is installed at: http://localhost/index.php
INFO [2015-07-01 07:02:15] Running Piwik 2.13.0 as Super User
ERROR [2015-07-01 07:02:15] Got invalid response from API request: http://localhost/index.php?module=API&method=API.getDefaultMetricTranslations&format=original> &serialize=1&trigger=archivephp. Response was ' <title>Object not found!</title> <style type="text/css">

@diosmosis
Copy link
Member

Perhaps the user that runs the web server or runs PHP is not allowed to connect to the internet? Did you run your test scripts in the same way IIS does or did you run them directly through php.exe? Can you connect to localhost or 127.0.0.1 through something hosted on IIS? I'm not familiar w/ IIS, but it sounds like a system configuration issue to me.

@Fensterbank
Copy link
Contributor Author

Hello again,

changing the running user did not help.
But I solved the issue, and yes, it was a crazy configuration problem!
A few months ago I followed the advice on http://piwik.org/faq/troubleshooting/#faq_121 because the update check didn't worked and added the following lines to my config.ini.php:

[proxy]
host = "proxy.abcdefghi.com"
port = 8000

But like you see in this issue, it never helped, Piwik could never connect somewhere.
Now I removed this proxy setting and the console archive script works! 👍
The update check and auto update does still not work, but I don't care, I will update manually.

Maybe it has something to do that Piwik used the configured proxy to connect to its hostname while the hostname is not available from outside the intranet. Using a proxy to connect to an intranet site would be wrong. Maybe half a bug here?

While using force_ssl = 1, I had to add --accept-invalid-ssl-certificate to get the script working (the ssl certificate is valid in our corporation, but I think piwik is using another cert store), but finally it works for me good enough.

You can close the issue.

@diosmosis
Copy link
Member

Maybe it has something to do that Piwik used the configured proxy to connect to its hostname while the hostname is not available from outside the intranet. Using a proxy to connect to an intranet site would be wrong. Maybe half a bug here?

I don't think the proxy settings should be used when connecting to localhost/127.0.0.1. I created an issue here: #8272

@tassoman
Copy link
Contributor

I wonder this modification slows my development on local machine while I'm behind company's proxy because of my http://piwik.local installation runs on localhost apache also if I connect to it from another LAN machine. Piwik is prevented to download remote content.

Can we add a force_use=1 inside [Proxy] INI config?

Temporarily, I've disabled outer http fetching as explained in #6324

@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

5 participants