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

client->get never sends requests #5

Open
rmacster opened this issue Dec 7, 2016 · 2 comments
Open

client->get never sends requests #5

rmacster opened this issue Dec 7, 2016 · 2 comments

Comments

@rmacster
Copy link

rmacster commented Dec 7, 2016

Using wireshark and firefox/copper I can get/put to my coap enabled device and see the appropriate data going back and forth. Using the client example I can see that the client->get method is called but nothing is ever returned to the closure/callback. In addition, wireshark says no request is being sent, (hence the callback issue). The server example works fine.

Thanks for your attention.

`<?php

include_once("vendor/autoload.php");

$loop = React\EventLoop\Factory::create();
echo "1\n";
$client = new PhpCoap\Client\Client( $loop );
echo "2\n";
//echo "Getting: $argv[1]\n";
$client->get( 'coap://192.168.100.113:5683/molex/actuators/red', function( $data ) {
//$client->get( $argv[1], function( $data ) {
    echo "3\n";
    var_dump( $data );
    $decoded_data = \CBOR\CBOREncoder::decode($data);
    echo "4\n";
    foreach($decoded_data as $key=>$val){
        echo "+\n";
        echo "$key: $val\n";
    } 
    echo "5\n";
    die;
} );
echo "6\n";
$loop->run();

?>`

@pjeutr
Copy link

pjeutr commented Dec 22, 2021

Same here, Server is working great. Client fails.
Really need this now to prototype something, stuff seems to go wrong in CoapPdu.php
Having a hardtime deciphering the bit-shifting without code comments, not really my cup of tea...

I also noticed in CoapRequest the uriPath is handed through with slashes.
Using this to calculate the count for the parts.

$pieces = explode('/', substr( $this->uriParts['path'], 1 ));
$uri = $pieces[0].chr(strlen($pieces[1])).$pieces[1].chr(strlen($pieces[2])).$pieces[2];

From what I could find, not much is happening with coap and php.
Anybody else knows a good project? I'm not really in the mood to do it in C

@pjeutr
Copy link

pjeutr commented Dec 23, 2021

Ended up converting the url used in calls form coap://local.dev/input/1/3333 to coap://local.dev/input-1-3333
Using deeper paths messes up $opt->length(), debugging took me too much time.

Also remove $this->addOption( new CoapOption( 3, $this->getHost() ) ); CoapRequest.php:22
see https://github.com/pjeutr/php-coap

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

No branches or pull requests

2 participants