shamblett / coap

A Coap package for dart
Other
16 stars 13 forks source link

COaP client: ping request not works with ESP server #18

Closed anayajoshi closed 3 years ago

anayajoshi commented 3 years ago

Hi @shamblett , I am using your ping request example. I works with coap.me server, but does not work with my ESP server. It returns false after ping timeout. Whereas, all other requests such as get, put etc. works with my ESP server. Also from IOT CoaP app of play store, ping request returns true with my ESP server. Only problem with my application. Please guide me. HERE IS MY CODE:

import 'package:coap/coap.dart'; import 'package:flutter/material.dart'; import 'package:flutter_app/coap_config.dart';

void main() { runApp(MyApp(null)); }

// final client; var count = 1;

class MyApp extends StatelessWidget { CoapClient client;

MyApp(this.client);

// This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(client, title: 'Flutter Demo Home Page'), ); } }

class MyHomePage extends StatefulWidget { CoapClient client;

// MyHomePage(this.client); MyHomePage(this.client, {Key key, this.title}) : super(key: key);

final String title;

@override _MyHomePageState createState() => _MyHomePageState(); }

class _MyHomePageState extends State { int _counter = 0;

void _incrementCounter() async { print('ISSUE: First getPut'); // if (_counter == 0) { // sendPing(); sendGet(); // } // await getPut(count); // await sendCoap();

setState(() {
  // sendCoap();
  _counter++;
});

}

@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headline4, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); }

sendPing() async {

// Create a configuration class. Logging levels can be specified in
// the configuration file.
final conf = CoapConfig();

// Build the request uri, note that the request paths/query parameters can be changed
// on the request anytime after this initial setup.
// const host = 'coap.me';
const host = '192.168.1.16';

final uri = Uri(scheme: 'coap', host: host, port: conf.defaultPort);

// Create the client.
// The method we are using creates its own request so we do
// not need to supply one.
// The current request is always available from the client.
final client = CoapClient(uri, conf);

print('EXAMPLE - Ping client, sending ping request to '
    '$host, waiting for response....');

// Perform the ping
final pingOk = await client.ping(10000);

if (pingOk) {
  print('EXAMPLE - Ping response OK ');
} else {
  print('EXAMPLE  - Ping failed');
}

// Cancel the current request
print('EXAMPLE  - Cleaning up');
client.close();

// exit(0);

}

shamblett commented 3 years ago

Please supply two logs, one with your code and the coap.me server and one with your code and the ESP server.

anayajoshi commented 3 years ago

Ok, please check the log as per requirement.

Ping request log with coap.me server:

2021-01-05 11:13:59.047 17430-17498/com.example.flutter_app I/flutter: EXAMPLE - Ping client, sending ping request to coap.me, waiting for response.... 2021-01-05 11:14:01.685 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:01.645: SEVERE: >> BlockwiseLayer uses MaxMessageSize: 1024 and DefaultBlockSize: 512 2021-01-05 11:14:01.703 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:01.703: INFO: >> CoapNetworkUDP - binding to 0.0.0.0 2021-01-05 11:14:01.716 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:01.715: INFO: >> Starting endpoint bound to InternetAddress('134.102.218.18', IPv4) 2021-01-05 11:14:01.782 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:01.782: INFO: >> Reliability - Scheduling transmission for <<< Request Message >>> Type: 0, Code: Empty Message, Id: 13729, Token: 00, Options = [ If-Match : Uri Host : Uri-Host: coap.me E-tags : None Uri Port : 5683 Location Paths: Uri Paths : Content-Type : None Max Age : None Uri Queries : Accept : None Location Queries : Proxy Uri : None Proxy Scheme : None Block 1 : None Block 2 : None Observe : -1 Size 1 : 0 Size 2 : 0 ], Payload : null 2021-01-05 11:14:01.789 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:01.789: INFO: >> Reliability - sending request, failed transmission count: 0 2021-01-05 11:14:01.791 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:01.790: INFO: >> Reliability - Retransmission timeout is 3564 ms 2021-01-05 11:14:01.804 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:01.803: INFO: >> Matcher - Stored open request by KeyID[13729]) + KeyToken[00] 2021-01-05 11:14:01.838 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:01.837: INFO: >> CoapNetworkUDP - binding to 0.0.0.0 2021-01-05 11:14:05.365 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.364: WARNING: >> Reliability - Retransmission timeout elapsed 2021-01-05 11:14:05.368 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.368: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 13729 2021-01-05 11:14:05.372 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.372: INFO: >> Reliability - Scheduling transmission for <<< Request Message >>> Type: 0, Code: Empty Message, Id: 13729, Token: 00, Options = [ If-Match : Uri Host : Uri-Host: coap.me E-tags : None Uri Port : 5683 Location Paths: Uri Paths : Content-Type : None Max Age : None Uri Queries : Accept : None Location Queries : Proxy Uri : None Proxy Scheme : None Block 1 : None Block 2 : None Observe : -1 Size 1 : 0 Size 2 : 0 ], Payload : null 2021-01-05 11:14:05.373 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.372: INFO: >> Reliability - sending request, failed transmission count: 0 2021-01-05 11:14:05.374 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.373: INFO: >> Reliability - Retransmission timeout is 3892 ms 2021-01-05 11:14:05.375 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.374: INFO: >> Matcher - Stored open request by KeyID[13729]) + KeyToken[00] 2021-01-05 11:14:05.733 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.733: INFO: >> Exchange got reply: Cleaning up KeyID[13729]) 2021-01-05 11:14:05.741 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.740: INFO: >> Reliability - Cancel retransmission for token: 00 id: 13729 2021-01-05 11:14:11.704 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:11.704: INFO: >> Start Mark-And-Sweep with 0 entries

2021-01-05 11:14:11.744 17430-17498/com.example.flutter_app I/flutter: EXAMPLE - Ping response OK

2021-01-05 11:14:11.744 17430-17498/com.example.flutter_app I/flutter: EXAMPLE - Cleaning up 2021-01-05 11:14:11.746 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:11.745: INFO: >> Close - closing client 2021-01-05 11:14:11.749 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:11.748: INFO: >> Endpoint - stopping endpoint bound to InternetAddress('134.102.218.18', IPv4) 2021-01-05 11:14:11.752 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:11.751: INFO: >> Network UDP - closing coap.me, port 5683 2021-01-05 11:14:11.760 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:11.760: INFO: >> Stopping Mark-And-Sweep 2021-01-05 11:14:11.780 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:11.779: INFO: >> Network UDP - closing coap.me, port 5683

anayajoshi commented 3 years ago

Ping request log with ESP server:

Performing hot reload... Syncing files to device KOB L09... Reloaded 1 of 594 libraries in 1,081ms. I/flutter (13065): 2021-01-05 12:22:49.451: INFO: >> Start Mark-And-Sweep with 0 entries I/flutter (13065): ISSUE: First getPut I/flutter (13065): EXAMPLE - Ping client, sending ping request to 192.168.1.8, waiting for response.... I/flutter (13065): 2021-01-05 12:22:57.705: SEVERE: >> BlockwiseLayer uses MaxMessageSize: 1024 and DefaultBlockSize: 512 I/flutter (13065): 2021-01-05 12:22:57.708: INFO: >> CoapNetworkUDP - binding to 0.0.0.0 I/flutter (13065): 2021-01-05 12:22:57.710: INFO: >> Starting endpoint bound to InternetAddress('192.168.1.8', IPv4) I/flutter (13065): 2021-01-05 12:22:57.718: INFO: >> Reliability - Scheduling transmission for I/flutter (13065): <<< Request Message >>> I/flutter (13065): Type: 0, Code: Empty Message, Id: 11669, Token: 00, I/flutter (13065): Options = I/flutter (13065): [ I/flutter (13065): If-Match : I/flutter (13065): Uri Host : Uri-Host: 192.168.1.8 I/flutter (13065): E-tags : I/flutter (13065): None I/flutter (13065): Uri Port : 5683 I/flutter (13065): Location Paths: I/flutter (13065): Uri Paths : I/flutter (13065): Content-Type : None I/flutter (13065): Max Age : None I/flutter (13065): Uri Queries : I/flutter (13065): Accept : None I/flutter (13065): Location Queries : I/flutter (13065): Proxy Uri : None I/flutter (13065): Proxy Scheme : None I/flutter (13065): Block 1 : None I/flutter (13065): Block 2 : None I/flutter (13065): Observe : -1 I/flutter (13065): Size 1 : 0 I/flutter (13065): Size 2 : 0 I/flutter (13065): ], I/flutter (13065): Payload : I/flutter (13065): null I/flutter (13065): 2021-01-05 12:22:57.719: INFO: >> Reliability - sending request, failed transmission count: 0 I/flutter (13065): 2021-01-05 12:22:57.720: INFO: >> Reliability - Retransmission timeout is 3694 ms I/flutter (13065): 2021-01-05 12:22:57.722: INFO: >> Matcher - Stored open request by KeyID[11669]) + KeyToken[00] I/flutter (13065): 2021-01-05 12:22:57.729: INFO: >> CoapNetworkUDP - binding to 0.0.0.0 I/flutter (13065): 2021-01-05 12:22:59.427: INFO: >> Start Mark-And-Sweep with 0 entries I/flutter (13065): 2021-01-05 12:23:01.416: WARNING: >> Reliability - Retransmission timeout elapsed I/flutter (13065): 2021-01-05 12:23:01.417: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 11669 I/flutter (13065): 2021-01-05 12:23:01.419: INFO: >> Reliability - Scheduling transmission for I/flutter (13065): <<< Request Message >>> I/flutter (13065): Type: 0, Code: Empty Message, Id: 11669, Token: 00, I/flutter (13065): Options = I/flutter (13065): [ I/flutter (13065): If-Match : I/flutter (13065): Uri Host : Uri-Host: 192.168.1.8 I/flutter (13065): E-tags : I/flutter (13065): None I/flutter (13065): Uri Port : 5683 I/flutter (13065): Location Paths: I/flutter (13065): Uri Paths : I/flutter (13065): Content-Type : None I/flutter (13065): Max Age : None I/flutter (13065): Uri Queries : I/flutter (13065): Accept : None I/flutter (13065): Location Queries : I/flutter (13065): Proxy Uri : None I/flutter (13065): Proxy Scheme : None I/flutter (13065): Block 1 : None I/flutter (13065): Block 2 : None I/flutter (13065): Observe : -1 I/flutter (13065): Size 1 : 0 I/flutter (13065): Size 2 : 0 I/flutter (13065): ], I/flutter (13065): Payload : I/flutter (13065): null I/flutter (13065): 2021-01-05 12:23:01.420: INFO: >> Reliability - sending request, failed transmission count: 0 I/flutter (13065): 2021-01-05 12:23:01.421: INFO: >> Reliability - Retransmission timeout is 3721 ms I/flutter (13065): 2021-01-05 12:23:01.422: INFO: >> Matcher - Stored open request by KeyID[11669]) + KeyToken[00] I/flutter (13065): 2021-01-05 12:23:05.145: WARNING: >> Reliability - Retransmission timeout elapsed I/flutter (13065): 2021-01-05 12:23:05.145: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 11669 I/flutter (13065): 2021-01-05 12:23:05.151: INFO: >> Reliability - Scheduling transmission for I/flutter (13065): <<< Request Message >>> I/flutter (13065): Type: 0, Code: Empty Message, Id: 11669, Token: 00, I/flutter (13065): Options = I/flutter (13065): [ I/flutter (13065): If-Match : I/flutter (13065): Uri Host : Uri-Host: 192.168.1.8 I/flutter (13065): E-tags : I/flutter (13065): None I/flutter (13065): Uri Port : 5683 I/flutter (13065): Location Paths: I/flutter (13065): Uri Paths : I/flutter (13065): Content-Type : None I/flutter (13065): Max Age : None I/flutter (13065): Uri Queries : I/flutter (13065): Accept : None I/flutter (13065): Location Queries : I/flutter (13065): Proxy Uri : None I/flutter (13065): Proxy Scheme : None I/flutter (13065): Block 1 : None I/flutter (13065): Block 2 : None I/flutter (13065): Observe : -1 I/flutter (13065): Size 1 : 0 I/flutter (13065): Size 2 : 0 I/flutter (13065): ], I/flutter (13065): Payload : I/flutter (13065): null I/flutter (13065): 2021-01-05 12:23:05.152: INFO: >> Reliability - sending request, failed transmission count: 0 I/flutter (13065): 2021-01-05 12:23:05.153: INFO: >> Reliability - Retransmission timeout is 3186 ms I/flutter (13065): 2021-01-05 12:23:05.154: INFO: >> Matcher - Stored open request by KeyID[11669]) + KeyToken[00] I/flutter (13065): 2021-01-05 12:23:07.710: INFO: >> Start Mark-And-Sweep with 0 entries

I/flutter (13065): EXAMPLE - Ping failed

I/flutter (13065): EXAMPLE - Cleaning up I/flutter (13065): 2021-01-05 12:23:07.719: INFO: >> Close - closing client I/flutter (13065): 2021-01-05 12:23:07.722: INFO: >> Endpoint - stopping endpoint bound to InternetAddress('192.168.1.8', IPv4) I/flutter (13065): 2021-01-05 12:23:07.724: INFO: >> Network UDP - closing 192.168.1.8, port 5683 I/flutter (13065): 2021-01-05 12:23:07.733: INFO: >> Stopping Mark-And-Sweep I/flutter (13065): 2021-01-05 12:23:07.745: INFO: >> Network UDP - closing 192.168.1.8, port 5683 I/flutter (13065): 2021-01-05 12:23:08.342: WARNING: >> Reliability - Retransmission timeout elapsed I/flutter (13065): 2021-01-05 12:23:08.342: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 11669 I/flutter (13065): 2021-01-05 12:23:08.343: INFO: >> Reliability - Scheduling transmission for I/flutter (13065): <<< Request Message >>> I/flutter (13065): Type: 0, Code: Empty Message, Id: 11669, Token: 00, I/flutter (13065): Options = I/flutter (13065): [ I/flutter (13065): If-Match : I/flutter (13065): Uri Host : Uri-Host: 192.168.1.8 I/flutter (13065): E-tags : I/flutter (13065): None I/flutter (13065): Uri Port : 5683 I/flutter (13065): Location Paths: I/flutter (13065): Uri Paths : I/flutter (13065): Content-Type : None I/flutter (13065): Max Age : None I/flutter (13065): Uri Queries : I/flutter (13065): Accept : None I/flutter (13065): Location Queries : I/flutter (13065): Proxy Uri : None I/flutter (13065): Proxy Scheme : None I/flutter (13065): Block 1 : None I/flutter (13065): Block 2 : None I/flutter (13065): Observe : -1 I/flutter (13065): Size 1 : 0 I/flutter (13065): Size 2 : 0 I/flutter (13065): ], I/flutter (13065): Payload : I/flutter (13065): null I/flutter (13065): 2021-01-05 12:23:08.344: INFO: >> Reliability - sending request, failed transmission count: 0 I/flutter (13065): 2021-01-05 12:23:08.345: INFO: >> Reliability - Retransmission timeout is 3430 ms I/flutter (13065): 2021-01-05 12:23:08.345: INFO: >> Matcher - Stored open request by KeyID[11669]) + KeyToken[00] E/flutter (13065): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Bad state: Cannot add new events after calling close E/flutter (13065): #0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:249:24) E/flutter (13065): #1 EventBus.fire (package:event_bus/event_bus.dart:61:22) E/flutter (13065): #2 CoapEventBus.fire (package:coap/src/event/coap_event_bus.dart:153:17) E/flutter (13065): #3 CoapEndPoint.sendRequest (package:coap/src/net/coap_endpoint.dart:177:15) E/flutter (13065): #4 CoapStackBottomLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:110:21) E/flutter (13065): #5 CoapNextLayer.sendRequest (package:coap/src/stack/coap_layer_stack.dart:20:10) E/flutter (13065): #6 CoapAbstractLayer.sendRequest (package:coap/src/stack/coap_abstract_layer.dart:18:15) E/flutter (13065): #7 CoapReliabilityLayer.sendRequest (package:coap/src/stack/coap_reliability_layer.dart:140:11) E/flutter (13065): #8 CoapReliabilityLayer.sendRequest. (package:coap/src/stack/coap_reliability_layer.dart:137:28) E/flutter (13065): #9 CoapTransmissionContext._timerElapsed (package:coap/src/stack/coap_reliability_layer.dart:98:20) E/flutter (13065): #10 _rootRun (dart:async/zone.dart:1182:47) E/flutter (13065): #11 _CustomZone.run (dart:async/zone.dart:1093:19) E/flutter (13065): #12 _CustomZone.runGuarded (dart:async/zone.dart:997:7) E/flutter (13065): #13 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23) E/flutter (13065): #14 _rootRun (dart:async/zone.dart:1190:13) E/flutter (13065): #15 _CustomZone.run (dart:async/zone.dart:1093:19) E/flutter (13065): #16 _CustomZone.bindCallback. (dart:async/zone.dart:1021:23) E/flutter (13065): #17 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15) E/flutter (13065): #18 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19) E/flutter (13065): #19 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5) E/flutter (13065): #20 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12) E/flutter (13065): I/flutter (13065): 2021-01-05 12:23:09.426: INFO: >> Start Mark-And-Sweep with 0 entries I/flutter (13065): 2021-01-05 12:23:11.777: WARNING: >> Reliability - Retransmission timeout elapsed I/flutter (13065): 2021-01-05 12:23:11.778: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 11669 I/flutter (13065): 2021-01-05 12:23:11.778: INFO: >> Reliability - Scheduling transmission for I/flutter (13065): <<< Request Message >>> I/flutter (13065): Type: 0, Code: Empty Message, Id: 11669, Token: 00, I/flutter (13065): Options = I/flutter (13065): [ I/flutter (13065): If-Match : I/flutter (13065): Uri Host : Uri-Host: 192.168.1.8 I/flutter (13065): E-tags : I/flutter (13065): None I/flutter (13065): Uri Port : 5683 I/flutter (13065): Location Paths: I/flutter (13065): Uri Paths : I/flutter (13065): Content-Type : None I/flutter (13065): Max Age : None I/flutter (13065): Uri Queries : I/flutter (13065): Accept : None I/flutter (13065): Location Queries : I/flutter (13065): Proxy Uri : None I/flutter (13065): Proxy Scheme : None I/flutter (13065): Block 1 : None I/flutter (13065): Block 2 : None I/flutter (13065): Observe : -1

anayajoshi commented 3 years ago

Get request log with ESP server: It works well

Launching lib/main.dart on KOB L09 in debug mode... Running Gradle task 'assembleDebug'... ✓ Built build/app/outputs/flutter-apk/app-debug.apk. Installing build/app/outputs/flutter-apk/app.apk... Waiting for KOB L09 to report its views... Debug service listening on ws://127.0.0.1:54080/hhTGGC6dJYg=/ws Syncing files to device KOB L09... I/flutter (13065): ISSUE: First getPut I/flutter (13065): ISSUE: Sending GET request... I/flutter (13065): 2021-01-05 12:19:59.376: SEVERE: >> BlockwiseLayer uses MaxMessageSize: 1024 and DefaultBlockSize: 512 I/flutter (13065): 2021-01-05 12:19:59.430: INFO: >> CoapNetworkUDP - binding to 0.0.0.0 I/flutter (13065): 2021-01-05 12:19:59.443: INFO: >> Starting endpoint bound to InternetAddress('192.168.1.8', IPv4) I/flutter (13065): 2021-01-05 12:19:59.518: INFO: >> Reliability - Scheduling transmission for I/flutter (13065): <<< Request Message >>> I/flutter (13065): Type: 0, Code: GET, Id: 31481, Token: 00006c88, I/flutter (13065): Options = I/flutter (13065): [ I/flutter (13065): If-Match : I/flutter (13065): Uri Host : Uri-Host: 192.168.1.8 I/flutter (13065): E-tags : I/flutter (13065): None I/flutter (13065): Uri Port : 5683 I/flutter (13065): Location Paths: I/flutter (13065): Uri Paths : inline I/flutter (13065): Content-Type : None I/flutter (13065): Max Age : None I/flutter (13065): Uri Queries : Uri-Query: devdetails I/flutter (13065): Accept : None I/flutter (13065): Location Queries : I/flutter (13065): Proxy Uri : None I/flutter (13065): Proxy Scheme : None I/flutter (13065): Block 1 : None I/flutter (13065): Block 2 : None I/flutter (13065): Observe : -1 I/flutter (13065): Size 1 : 0 I/flutter (13065): Size 2 : 0 I/flutter (13065): ], I/flutter (13065): Payload : I/flutter (13065): null I/flutter (13065): 2021-01-05 12:19:59.525: INFO: >> Reliability - sending request, failed transmission count: 0 I/flutter (13065): 2021-01-05 12:19:59.527: INFO: >> Reliability - Retransmission timeout is 3037 ms I/flutter (13065): 2021-01-05 12:19:59.539: INFO: >> Matcher - Stored open request by KeyID[31481]) + KeyToken[00006c88] I/flutter (13065): 2021-01-05 12:19:59.573: INFO: >> CoapNetworkUDP - binding to 0.0.0.0 I/flutter (13065): 2021-01-05 12:20:02.574: WARNING: >> Reliability - Retransmission timeout elapsed I/flutter (13065): 2021-01-05 12:20:02.576: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 31481 I/flutter (13065): 2021-01-05 12:20:02.578: INFO: >> Reliability - Scheduling transmission for I/flutter (13065): <<< Request Message >>> I/flutter (13065): Type: 0, Code: GET, Id: 31481, Token: 00006c88, I/flutter (13065): Options = I/flutter (13065): [ I/flutter (13065): If-Match : I/flutter (13065): Uri Host : Uri-Host: 192.168.1.8 I/flutter (13065): E-tags : I/flutter (13065): None I/flutter (13065): Uri Port : 5683 I/flutter (13065): Location Paths: I/flutter (13065): Uri Paths : inline I/flutter (13065): Content-Type : None I/flutter (13065): Max Age : None I/flutter (13065): Uri Queries : Uri-Query: devdetails I/flutter (13065): Accept : None I/flutter (13065): Location Queries : I/flutter (13065): Proxy Uri : None I/flutter (13065): Proxy Scheme : None I/flutter (13065): Block 1 : None I/flutter (13065): Block 2 : None I/flutter (13065): Observe : -1 I/flutter (13065): Size 1 : 0 I/flutter (13065): Size 2 : 0 I/flutter (13065): ], I/flutter (13065): Payload : I/flutter (13065): null I/flutter (13065): 2021-01-05 12:20:02.579: INFO: >> Reliability - sending request, failed transmission count: 0 I/flutter (13065): 2021-01-05 12:20:02.580: INFO: >> Reliability - Retransmission timeout is 3433 ms I/flutter (13065): 2021-01-05 12:20:02.581: INFO: >> Matcher - Stored open request by KeyID[31481]) + KeyToken[00006c88] I/flutter (13065): 2021-01-05 12:20:02.817: INFO: >> Matcher - received response I/flutter (13065): <<< Response Message >>> I/flutter (13065): Type: 2, Code: 2.05 Content, Id: 31481, Token: 00006c88, I/flutter (13065): Options = I/flutter (13065): [ I/flutter (13065): If-Match : I/flutter (13065): Uri Host : None I/flutter (13065): E-tags : ETag: 1511e80e I/flutter (13065): None I/flutter (13065): Uri Port : None I/flutter (13065): Location Paths: I/flutter (13065): Uri Paths : I/flutter (13065): Content-Type : 50 I/flutter (13065): Max Age : 0 I/flutter (13065): Uri Queries : I/flutter (13065): Accept : -1 I/flutter (13065): Location Queries : I/flutter (13065): Proxy Uri : None I/flutter (13065): Proxy Scheme : None I/flutter (13065): Block 1 : None I/flutter (13065): Block 2 : None I/flutter (13065): Observe : -1 I/flutter (13065): Size 1 : 0 I/flutter (13065): Size 2 : 0 I/flutter (13065): ], I/flutter (13065): Payload : I/flutter (13065): {"srno":"DDDDDDDDDD","device":"C013","proj":"107","flor":"0","room":"105","area":"116","prid":17,"pvid":1,"pcid":1} I/flutter (13065): 2021-01-05 12:20:02.820: INFO: >> Matcher - cleaning up KeyID[31481]) I/flutter (13065): 2021-01-05 12:20:02.828: INFO: >> Reliability - Cancel retransmission for token: 00006c88 id: 31481 I/flutter (13065): ISSUE: - GET response received I/flutter (13065): {"srno":"DDDDDDDDDD","device":"C013","proj":"107","flor":"0","room":"105","area":"116","prid":17,"pvid":1,"pcid":1} I/flutter (13065): 2021-01-05 12:20:02.858: INFO: >> Matcher - Exchange completed: Cleaning up KeyToken[00006c88] I/flutter (13065): 2021-01-05 12:20:09.430: INFO: >> Start Mark-And-Sweep with 1 entries I/flutter (13065): 2021-01-05 12:20:09.435: INFO: >> Mark-And-Sweep removes KeyID[31481]) I/flutter (13065): 2021-01-05 12:20:19.426: INFO: >> Start Mark-And-Sweep with 0 entries

shamblett commented 3 years ago

You are printing 'I/flutter (13065): EXAMPLE - Ping failed' then cleaning up before you have a response from your server, previous to this you are just sending request messages there is no response, you need to run this for longer to give your server chance to respond or find out why it isn't. Presumably your ESP server produces its own logs, you may need to look at these in conjunction with the client logs.

anayajoshi commented 3 years ago

No, It is printing 'I/flutter (13065): EXAMPLE - Ping failed' after receiving response. Ping method responds only true or false right? The same ESP server returns true in 'Iot COaP' app from play store. Then why it returns always false in my app only, where as all other requests to the same server works well?

shamblett commented 3 years ago

In the log for coap.me I'm seeing -

2021-01-05 11:14:05.375 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.374: INFO: >> Matcher - Stored open request by KeyID[13729]) + KeyToken[00]
2021-01-05 11:14:05.733 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.733: INFO: >> Exchange got reply: Cleaning up KeyID[13729])
2021-01-05 11:14:05.741 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.740: INFO: >> Reliability - Cancel retransmission for token: 00 id: 13729

Just before the Ping response OK, I'm not seeing this in the ESP log , I can't see the 'got reply' entry, maybe my eyes if its there please point it out to me.

anayajoshi commented 3 years ago

In the log for coap.me I'm seeing -

2021-01-05 11:14:05.375 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.374: INFO: >> Matcher - Stored open request by KeyID[13729]) + KeyToken[00]
2021-01-05 11:14:05.733 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.733: INFO: >> Exchange got reply: Cleaning up KeyID[13729])
2021-01-05 11:14:05.741 17430-17498/com.example.flutter_app I/flutter: 2021-01-05 11:14:05.740: INFO: >> Reliability - Cancel retransmission for token: 00 id: 13729

Just before the Ping response OK, I'm not seeing this in the ESP log , I can't see the 'got reply' entry, maybe my eyes if its there please point it out to me.

ok, I will check again

anayajoshi commented 3 years ago

I removed close statement, I think it gives response after the timeout as false. It is not working. Where as from the IOT coap application, the same ESP server returns true.

The log output is as below:

Running Gradle task 'assembleDebug'... ✓ Built build/app/outputs/flutter-apk/app-debug.apk. Installing build/app/outputs/flutter-apk/app.apk... Waiting for KOB L09 to report its views... Debug service listening on ws://127.0.0.1:64626/VGU4KEThi3s=/ws Syncing files to device KOB L09... I/hwaps (20685): JNI_OnLoad I/flutter (20685): ISSUE: First getPut I/flutter (20685): EXAMPLE - Ping client, sending ping request to 192.168.1.3, waiting for response.... I/flutter (20685): 2021-01-05 17:11:12.632: SEVERE: >> BlockwiseLayer uses MaxMessageSize: 1024 and DefaultBlockSize: 512 I/flutter (20685): 2021-01-05 17:11:12.704: INFO: >> CoapNetworkUDP - binding to 0.0.0.0 I/flutter (20685): 2021-01-05 17:11:12.724: INFO: >> Starting endpoint bound to InternetAddress('192.168.1.3', IPv4) I/flutter (20685): 2021-01-05 17:11:12.832: INFO: >> Reliability - Scheduling transmission for I/flutter (20685): <<< Request Message >>> I/flutter (20685): Type: 0, Code: Empty Message, Id: 30659, Token: 00, I/flutter (20685): Options = I/flutter (20685): [ I/flutter (20685): If-Match : I/flutter (20685): Uri Host : Uri-Host: 192.168.1.3 I/flutter (20685): E-tags : I/flutter (20685): None I/flutter (20685): Uri Port : 5683 I/flutter (20685): Location Paths: I/flutter (20685): Uri Paths : I/flutter (20685): Content-Type : None I/flutter (20685): Max Age : None I/flutter (20685): Uri Queries : I/flutter (20685): Accept : None I/flutter (20685): Location Queries : I/flutter (20685): Proxy Uri : None I/flutter (20685): Proxy Scheme : None I/flutter (20685): Block 1 : None I/flutter (20685): Block 2 : None I/flutter (20685): Observe : -1 I/flutter (20685): Size 1 : 0 I/flutter (20685): Size 2 : 0 I/flutter (20685): ], I/flutter (20685): Payload : I/flutter (20685): null I/flutter (20685): 2021-01-05 17:11:12.842: INFO: >> Reliability - sending request, failed transmission count: 0 I/flutter (20685): 2021-01-05 17:11:12.845: INFO: >> Reliability - Retransmission timeout is 4105 ms I/flutter (20685): 2021-01-05 17:11:12.862: INFO: >> Matcher - Stored open request by KeyID[30659]) + KeyToken[00] I/flutter (20685): 2021-01-05 17:11:12.920: INFO: >> CoapNetworkUDP - binding to 0.0.0.0 I/flutter (20685): 2021-01-05 17:11:16.964: WARNING: >> Reliability - Retransmission timeout elapsed I/flutter (20685): 2021-01-05 17:11:16.966: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 30659 I/flutter (20685): 2021-01-05 17:11:16.968: INFO: >> Reliability - Scheduling transmission for I/flutter (20685): <<< Request Message >>> I/flutter (20685): Type: 0, Code: Empty Message, Id: 30659, Token: 00, I/flutter (20685): Options = I/flutter (20685): [ I/flutter (20685): If-Match : I/flutter (20685): Uri Host : Uri-Host: 192.168.1.3 I/flutter (20685): E-tags : I/flutter (20685): None I/flutter (20685): Uri Port : 5683 I/flutter (20685): Location Paths: I/flutter (20685): Uri Paths : I/flutter (20685): Content-Type : None I/flutter (20685): Max Age : None I/flutter (20685): Uri Queries : I/flutter (20685): Accept : None I/flutter (20685): Location Queries : I/flutter (20685): Proxy Uri : None I/flutter (20685): Proxy Scheme : None I/flutter (20685): Block 1 : None I/flutter (20685): Block 2 : None I/flutter (20685): Observe : -1 I/flutter (20685): Size 1 : 0 I/flutter (20685): Size 2 : 0 I/flutter (20685): ], I/flutter (20685): Payload : I/flutter (20685): null I/flutter (20685): 2021-01-05 17:11:16.969: INFO: >> Reliability - sending request, failed transmission count: 0 I/flutter (20685): 2021-01-05 17:11:16.970: INFO: >> Reliability - Retransmission timeout is 4450 ms I/flutter (20685): 2021-01-05 17:11:16.971: INFO: >> Matcher - Stored open request by KeyID[30659]) + KeyToken[00] I/flutter (20685): pingOk = false I/flutter (20685): EXAMPLE - Ping failed I/flutter (20685): 2021-01-05 17:11:21.426: WARNING: >> Reliability - Retransmission timeout elapsed I/flutter (20685): 2021-01-05 17:11:21.426: WARNING: >> Reliability - Timeout: retransmit message, failed count: 1 message: 30659 I/flutter (20685): 2021-01-05 17:11:21.428: INFO: >> Reliability - Scheduling transmission for I/flutter (20685): <<< Request Message >>> I/flutter (20685): Type: 0, Code: Empty Message, Id: 30659, Token: 00, I/flutter (20685): Options = I/flutter (20685): [ I/flutter (20685): If-Match : I/flutter (20685): Uri Host : Uri-Host: 192.168.1.3 I/flutter (20685): E-tags : I/flutter (20685): None I/flutter (20685): Uri Port : 5683 I/flutter (20685): Location Paths: I/flutter (20685): Uri Paths : I/flutter (20685): Content-Type : None I/flutter (20685): Max Age : None I/flutter (20685): Uri Queries : I/flutter (20685): Accept : None I/flutter (20685): Location Queries : I/flutter (20685): Proxy Uri : None I/flutter (20685): Proxy Scheme : None I/flutter (20685): Block 1 : None I/flutter (20685): Block 2 : None I/flutter (20685): Observe : -1 I/flutter (20685): Size 1 : 0 I/flutter (20685): Size 2 : 0 I/flutter (20685): ], I/flutter (20685): Payload : I/flutter (20685): null I/flutter (20685): 2021-01-05 17:11:21.429: INFO: >> Reliability - sending request, failed transmission count: 0

The same code returns true for coap.me server. I am unable to find where is the problem? Please help me to identify and solve this issue.

anayajoshi commented 3 years ago

Hello @shamblett , I checked ping request from android application, it works well with same ESP server, but not works from flutter application. Please check it.

shamblett commented 3 years ago

What do you want me to check? The client works with coap.me, it doesn't work with the ESP server because as you have proved from your logs above the ESP server is not sending a response to the ping request, this could just as much be a fault with the ESP server as it could be with the client, you have to prove there is a fault in the client, e.g. something doesn't work with coap.me.

As I've said before I don't have an ESP server to check with, you have to find out why the ESP server isn't responding to ping requests from this client in the first instance. Statements like this 'I checked ping request from android application, it works well with same ESP server' are irrelevant to this issue which is concerned with this client, not anything else.