DeltaVetal26 / SteVe-OCPP-HTTP-Client

Basic HTTP client for sending commands remotely to the Steve OCPP control panel
10 stars 8 forks source link

None of the GET commands are working. #9

Open sijojamesjohn opened 12 months ago

sijojamesjohn commented 12 months ago

None of the GET commands are working. All of them are redirecting to the Signin page.

DeltaVetal26 commented 12 months ago

Hello,

https://github.com/DeltaVetal26/SteVe-OCPP-HTTP-Client/issues/8 Have you updated Steve?

If you have the latest version of Steve, try installing an earlier version. They probably changed the structure of the page and that's why it doesn't work.

I'll check it out when I have time.

unstuckdesign commented 12 months ago

Hi, I've got the same issue. I can get the POST commands to work and create entries in Steve. All GET commands seem to fail and redirect back to the login. JSESSIONID cookie is being set and is correct. Looks like something is causing an invalid session but not sure what. Thanks for any help.

sijojamesjohn commented 11 months ago

It is redirecting before it even reaches the page.

DeltaVetal26 commented 11 months ago

Hello. Sorry for delay.

Test conditions: 1) SteVe-3.6.0 2) OCPP v1.6 (JSON) 2) PHP 5.4.16-48.el7 (where is the script located)

Result: 1) Get connector state (From the browser): Command: https://website.com/main.php?key=MyKey&ChargeBoxID=HVG15&cmd=getConnectorState&ConnectorID=1 Result: image

2) Get connector state (cURL): Command: curl "https://website.com/main.php?key=MyKey&ChargeBoxID=HVG15&cmd=getConnectorState&ConnectorID=1" Result: image

There are no other GET commands in this script. When testing on the latest version, it did not return the connector state (It was always "StateNotExist"). I fixed this in the update.

Did you get an error with the get connector state command?

sijojamesjohn commented 11 months ago

Still getting the login page and the error is StateNotExist

steve 3.6.0 php 7.5 occp 1.6

DeltaVetal26 commented 11 months ago

I haven't found a PHP 7.5 version to test this with (After 7.4.33 there is already version 8.). I checked on PHP version 7.4.33 - OK. This script is not supported on PHP 8+.

As I understand it, all other commands work for you, with the exception of GET. I can't reproduce this issue. Do you have a PHP error log? Are there any errors when calling the script?

Perhaps the page does not have time to load and the command is already being sent. I can suggest trying to add a delay of a couple of seconds in the place where authorization is called.

Add sleep(3); after calling the steveSignIn function (It's at the bottom of the script.)

image image

UPD. Also add the content output to check in the steveSignIn function: Before:

  function steveSignIn($login, $pass) {
    global $curl, $steveServerAddres, $stevePathArray;
    $content = curlConnectTo($steveServerAddres, $stevePathArray['signin']);
    $token = getCSRFToken($content);
    $form = "username=".$login."&password=".$pass."&_csrf=".$token."";
    curl_setopt($curl, CURLOPT_POSTFIELDS, $form);
    curl_exec($curl);
  }

After:

  function steveSignIn($login, $pass) {
    global $curl, $steveServerAddres, $stevePathArray;
    $content = curlConnectTo($steveServerAddres, $stevePathArray['signin']);
    $token = getCSRFToken($content);
    $form = "username=".$login."&password=".$pass."&_csrf=".$token."";
    curl_setopt($curl, CURLOPT_POSTFIELDS, $form);
    $checkContent = curl_exec($curl);
    echo $checkContent;
  }

Next, run this script through a browser asking for the connector status. What will be displayed there?

RealRunSpace commented 10 hours ago

Hello there! Firts of all thanks for this little helpfull php. I was investigating why GET request weren't working, it's because when you use the sigin curl, it doesn't matter the URL you are pointing to, in the latests version, after signin, you go back to the "home/welcome" page, instead of logging in and loading the page you really requested