Assign inputs to a node group - example fails

OK, another show stopper for a beginner.

Having logged into emoncms on localhost, clicking Input, Feeds or Vis results in the error message

( ! ) Warning: stream_socket_client(): unable to connect to tcp://: (Failed to parse address ":") in E:\Wamp\www\emoncms\Modules\feed\engine\GraphiteTimeSeries.php on line 30

plus the call stack leading to the failing command.

Any suggestion about what's wrong?

Robert Wall's picture

Re: Assign inputs to a node group - example fails

As you have another post about WAMP, I assume that's the 'localhost' you are referring to.  If you look at the line that's failing, it is looking for a host and a port, which are apparently empty strings. That suggests you might not have set up emoncms correctly and you have a naming problem or possibly a permissions problem with WAMP. Have you put the correct information into settings.php?

Mithrass's picture

Re: Assign inputs to a node group - example fails

Thanks for mentoring, Robert.  Your assumption is right - I'm logged in to WAMP.

I followed up the error message to GraphiteTimeSeries.php.  Line 30 (by counting) is

$this->write_socket = stream_socket_client("tcp://$this->host:$this->port");  

which makes sense and suggests host and port are not defined.

I'm guessing that the definition is in settings.php.  I modified that file as per instructions and placed it in Wamp\www\emoncms.  I have attached the file (zipped) in case that helps.

I have some doubts about the WAMP setup because the installation instructions didn't work out exactly and i had to use some imagination.  The instructions says

On Wampserver, ...left-click on your Wamp icon and hover on Apache, then hover over Apache Modules, then click PHP.

PHP doesn't appear in Apache Modules but rewrite-module does, and there's php5_module right at the bottom.  I checked both of them.

I enabled gettext as instructed, and set up a database and user.  That all seemed to work and I was able to register and log in.  Then the error message started to appear. (At first it's obscured by the black banner at the top, so I'm not completely sure it's always the same.  The message I reported is as shown the first time it's exposed.)

My underlying problem is that I have no concept-level explanation of how it is intended to work, so  when anything departs from the explicit instructions I get lost.

I'm grateful for any advice you can offer.

 

Robert Wall's picture

Re: Assign inputs to a node group - example fails

I'll get my old Win XP machine out later and look at it for you. Watch this thread.

Mithrass's picture

Re: Assign inputs to a node group - example fails

I'm using Windows 7.  Is there something here that's critical on Windows version?

Robert Wall's picture

Re: Assign inputs to a node group - example fails

The "concept-level" is difficult in a few words, here goes:

PHP is a scripting language that is invoked by Apache, the web server program. It has an API that interfaces with the database, MySQL. Your data is stored in MySQL. The PHP script does two main functions. (1) receives data sent by the emonBase and puts it in the database, and (2) on demand it reads the database and produces graphs etc. It needs to know the user name and passwords etc to access the database, and it needs to know where the database is, i.e. its name etc. This is what you putin settings.php. It also requires passwords from the emonBase in the form of the APIkey, and from you when you log in.

PHP5 is the correct module, typically there are several ways of achieving the same objective and if it's ticked, that is fine. You wouldn't have got this far without it. Have you set up a database in MySQL? The usual way to do this is with PHPMyAdmin. I guess the answer is 'yes' as you've got a name for it in settings.php, and you've got a user name and a password for it.

What version of Windows, and do you have a permissions problem somewhere. If apparently not, I'm struggling - I think we need Trystan.

 

Mithrass's picture

Re: Assign inputs to a node group - example fails

Robert, thanks for taking the time to explain.  I really appreciate your efforts. That's a pretty good succinct explanation of how it works, and clarifies my perception that had been gradually emerging through trying things.  I had seen WAMP as a testbed for web pages, and not understood its SQL function.  One detail - I didn't understand "It also requires passwords from the emonBase in the form of the APIkey"  What is the APIkey?

Meanwhile, I'm going backwards here.  I managed to wreck the WAMP installation - the php5_module disappeared - so I reinstalled it (after uninstalling it first).  Now I can't get in to register as a user.

http://localhost is fine, and gets me to the WampServer base page and allows access to phpmyadmin to set up the database and user.  It shows I have a project called emoncms.  

But http://localhost/emoncms just gives this error message:

Can't connect to database, please verify credentials/configuration in settings.php
Error message: Access denied for user 'Frank'@'localhost' (using password: YES)

I've checked settings.php and everything else that I needed to set, but it's all correct and nothing makes any difference.

Really struggling here.  I've run out of ideas.

Robert Wall's picture

Re: Assign inputs to a node group - example fails

WAMP is an acronym for Windows Apache MySQL PHP.  The three (A, M & P) are bundled together because with that combination, you can do pretty much all the powerful things you need to do with a website. In the Linux world there's the LAMP stack and in the Apple Mac world there's MAMP (no prizes for what the first letter means).

If you go in to PHPMyAdmin, you have a database called emoncms (bad choice - I have to distinguish between the database and the PHP script of the same name!), you have a user of that database called Frank who has a password. You need to give Frank full permissions. Emoncms the script is using that ID 'Frank' and his password to log in to the database and send data to and read data from your database. Or at least it's trying to, but failing. You need to check that chain again.

When you first logged in to emoncms the script, you created a user name and password. Thereafter you use that same user name and password to access and edit the dashboards & data. At the same time that you created your user name in emoncms the script (not Frank's in emoncms the database), emoncms the script also created an APIkey, which is in effect a user name and password combined, that the emonBase (NanodeRF, Raspberry Pi) sends with the data to assure emoncms that it has permission to send it the data. Look at the Input API Help page in emoncms.

Mithrass's picture

Re: Assign inputs to a node group - example fails

Thanks Robert.  I'll have to spend some time following that up.  Little job for the weekend so the day job doesn't get in the way.  At first sight, what you describe is exactly what I have done - but I'll check through it again.  The failure occurs before that - localhost/emoncms rejects my attempt to login without ever asking for a password.

I think I need to explain what I'm about.  I'll send you a private message separately.

ukmoose's picture

Re: Assign inputs to a node group - example fails

As Robert explained.

 

The error is not YOU logging into EmonCMS but emoncms logging into MySQL.

When you followed the windows install instructions, you created the emoncms database in this step:

4) Create a MYSQL database

To create a database in phpmyadmin, click on Databases at the top, then enter 'emoncms' in the text input box and click create.

You also created a user (which according to your setting.php file is called "Frank")  and setup Franks password.  The same section of the instructions include the following: 

When, in phpmyadmin, the database has been created, a new user must also be created on host "localhost" (not "%") and have a password set. When the user has been created, the user needs to have "all" privileges over the new database that has just been created (scroll down for Database-specific privileges). Those 4 items - the new user name, password, "localhost" and database name are the values that go into the settings.php file.

 

 

Robert Wall's picture

Re: Assign inputs to a node group - example fails

I suggest you create a new database using PHPMyAdmin. DO NOT give it the same name as anything else (i.e. NOT emoncms), and create a new user (NOT your user name you'll use to log in to emoncms) with a totally different password. The purpose of the different names is so that YOU won't get confused. The machine will be fine.

I made that mistake the first time round and got into a right tangle, so learn from my mistake.

Mithrass's picture

Re: Assign inputs to a node group - example fails

Many thanks for the help, guys.  I have followed up the suggestions and  made some progress over the weekend.  My problem, with "Can't connect to database" was caused by confusion of the database name with the host name.  I think I have that fixed now, and learned a few other things by trial and error along the way.

So I'm back with the original problem.  Having registered and logged in to localhost/OtherBase as user Luke, as soon as I try to do anything such as select Input, Feeds or Vis, I see the message

( ! ) Warning: stream_socket_client(): unable to connect to tcp://: (Failed to parse address ":") in E:\Wamp\www\emoncms\Modules\feed\engine\GraphiteTimeSeries.php on line 30

Tracing this through the code, the failing statement is 

$this->write_socket = stream_socket_client("tcp://$this->host:$this->port");

which occurs in function connect_write() which is called by the GraphiteTimeSeries constructor.  That function assigns values to $this->host and $this->port using input parameters $host and $port.

The GraphiteTimeSeries constructor is called by the Feed constructor (feed_model.php, line 52), which passes parameters $graphite_host and $graphite_port.  These are declared as global, but I can't find anywhere where they are assigned values.

Am I missing a file?

Robert Wall's picture

Re: Assign inputs to a node group - example fails

This thread is relevant: http://openenergymonitor.org/emon/node/3728

But I don't know if this applies to you.

Mithrass's picture

Re: Assign inputs to a node group - example fails

Yes, that's the same error, and that fixes it.  I need to spend some time with the code to understand why.  Meanwhile, I'm making progress.

Thanks for all your help.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.