Giter Club home page Giter Club logo

dart_snmp's People

Contributors

charcoast avatar lmmfranco avatar point-source avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dart_snmp's Issues

How to just get the value dirctly without using any String methods?

I'm getting this results when I use this code :

import 'dart:io';
import 'package:dart_snmp/dart_snmp.dart';
import 'package:dart_snmp/src/models/varbind.dart';

void main() async {
  // Starting a session
  var target = InternetAddress('192.168.1.1');
  var session = await Snmp.createSession(target);

  // Reading a parameter
  var oid = Oid.fromString('1.3.6.1.4.1.43356.2.1.2.1.4.0'); // sysDesc
  var message = await session.get(oid);
  print(message.pdu.varbinds[0]); // outputs system description

  // Writing a parameter
  var varbind = Varbind(
    oid,
    VarbindType.OctetString,
    'New system description',
  ); // create payload
  await session.set(varbind); // send new system description to target
}

Results :

flutter: 1.3.6.1.4.1.43356.2.1.2.1.4.0 = OctetString: 2018-06-02 00:23:04 (UTC +0000)

I just want to get the value : 2018-06-02 00:23:04 (UTC +0000) without using any String Methods
is that possible ?
thanks for your great package πŸ’―

Unhandled Exception: Exception: Snmp Pdu Error on 1.3.6.1.2.1.1.5.0: WrongValue

Hi I have this problem when I try to send a new sysname to cisco via snmp using this command

It is already fetching the name, but when trying to set a name, it throws this error

and in the end thanx for this lib

flutter: INFO: 2022-01-30 04:47:48.265034: Snmp v2c session initialized.
flutter: INFO: 2022-01-30 04:47:48.284396: Bound to target 0.0.0.0 on port 56504

flutter: 1.3.6.1.2.1.1.5.0 = OctetString: hellow

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Bad state: Future already completed
#0 _AsyncCompleter.complete (dart:async/future_impl.dart:45:31)
#1 Request.complete (package:dart_snmp/src/models/request.dart:45:15)
#2 Snmp._onEvent (package:dart_snmp/src/snmp_base.dart:153:36)
#3 _rootRunUnary (dart:async/zone.dart:1444:13)
#4 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#5 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#9 _StreamController._add (dart:async/stream_controller.dart:607:7)
#10 _StreamController.add (dart:async/stream_controller.dart:554:5)
#11 new _RawDatagramSocket. (dart:io-patch/socket_patch.dart:2391:33)
#12 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1314:14)
#13 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#14 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Snmp Pdu Error on 1.3.6.1.2.1.1.5.0: WrongValue

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Bad state: Future already completed
#0 _Completer.completeError (dart:async/future_impl.dart:24:31)
#1 Request.completeError (package:dart_snmp/src/models/request.dart:49:49)
#2 Request.complete (package:dart_snmp/src/models/request.dart:42:7)
#3 Snmp._onEvent (package:dart_snmp/src/snmp_base.dart:153:36)
#4 _rootRunUnary (dart:async/zone.dart:1444:13)
#5 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
#6 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
#7 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#8 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#9 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
#10 _StreamController._add (dart:async/stream_controller.dart:607:7)
#11 _StreamController.add (dart:async/stream_controller.dart:554:5)
#12 new _RawDatagramSocket. (dart:io-patch/socket_patch.dart:2391:33)
#13 _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1314:14)
#14 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#15 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Bad state: Future already completed
#0 _Completer.completeError (dart:async/future_impl.dart:24:31)
#1 Request.completeError (package:dart_snmp/src/models/request.dart:49:49)
#2 Snmp._timeout (package:dart_snmp/src/snmp_base.dart:277:11)
#3 Snmp._send. (package:dart_snmp/src/snmp_base.dart:266:43)
#4 new Future.delayed. (dart:async/future.dart:393:39)
#5 _rootRun (dart:async/zone.dart:1420:47)
#6 _CustomZone.run (dart:async/zone.dart:1328:19)
#7 _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
#8 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1276:23)
#9 _rootRun (dart:async/zone.dart:1428:13)
#10 _CustomZone.run (dart:async/zone.dart:1328:19)
#11 _CustomZone.bindCallback. (dart:async/zone.dart:1260:23)
#12 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
#13 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:395:19)
#14 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:426:5)
#15 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

my code down blew

where i gone wrong ?

var target = InternetAddress('192.168.1.2');
  var session = await Snmp.createSession(target,port: 161 , community: "private");
  var oid = Oid.fromString('1.3.6.1.2.1.1.5.0');
  // sysDesc
  var message = await session.get(oid);


  print(message.pdu.varbinds[0]); // outputs system description


  var varbind = Varbind(
oid,
    VarbindType.OctetString,
    'New system description',
  ); // create payload
  await session.set(varbind);

Snmp on IOS

I'm currently using version:

  • flutter: 3.7.12
  • dart_snmp: 3.0.1
  • xCode: 14.3
  • IOS: 16.4

I need to scan my LAN and know what devices offer snmp service.
At the moment I do the procedure shown in the example for each ip address present in the local network.

When I run the code of the example (on IOS) I sometimes run into this error: SocketException (SocketException: Send failed (OS Error: No route to host, errno = 65), address = 0.0.0.0, port = 58340) (the reported port changes every time).
By sometimes I mean that for different executions it gives me errors on different ip addresses.

Thanks in advance

Snmp v3

I wanted to know if there is a release date for snmp v3. Thank you

How to build this line whit dart_snmp

Hello, from console I run it like this, but I would like to know how to pass it with dart_snmp thank you very much in advance.

snmpset -v2c -c public 192.168.100.1 1.3.6.1.4.1.4413.2.99.1.1.1.2.1.2.1 s password

HTTP calls not function after scan

As a continue of the Issue #20
I add that:

  • I added a try catch around the Future<void> _bind({InternetAddress? address, int? port}) function (in file snmp_base.dart) and the exception doesn't show up anymore (that's okay because I get the informations that I need to get)
  • after running the scan the other http calls no longer work (to do regular http call i use dio: 5.0.1)

Failed requests are not being removed from list

On the _set and _get methods the future is awaited and the request is removed from the list on the next line, however, is the request fails, the next line does not execute and the request map just keeps on growing.

I will be opening a pull request for this fix in a few minutes.

Gauge values are being set with Integer tag

Gauge and Counter varbinds are using Integer (2) tag instead of the desired (65/66), thus resulting in error when setting.

image

I will be opening a pull request for this fix in a few minutes.

Error to run dart_snmp

I have created a simple project with the example and when I tried run the code I have the error below:

Launching lib\main.dart on Chrome in debug mode...
lib\main.dart:1
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

  • package:dart_snmp
  • package:logging
  • package:asn1lib
    2

For solutions, see https://dart.dev/go/unsound-null-safety
Unhandled exception:
Bad state: Unsupported Null Safety mode NonNullableByDefaultCompiledMode.Invalid, in null.
#0 ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:439:9)
#1 JavaScriptBundler.compile (package:frontend_server/src/javascript_bundle.dart:146:33)
#2 FrontendCompiler.writeJavascriptBundle (package:frontend_server/frontend_server.dart:638:47)


Another attempt of run was with command "flutter run --no-sound-null-safety" but it’s also shown error:

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety

To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".
Error: Unsupported operation: InternetAddress
at Object.throw_ [as throw] (http://localhost:62159/dart_sdk.js:5344:11)
at Function.new (http://localhost:62159/dart_sdk.js:58997:17)
at main (http://localhost:62159/packages/printer_check/main.dart.lib.js:18:42)
at main.next ()
at runBody (http://localhost:62159/dart_sdk.js:39221:34)
at Object._async [as async] (http://localhost:62159/dart_sdk.js:39252:7)
at main$ (http://localhost:62159/packages/printer_check/main.dart.lib.js:17:18)
at main (http://localhost:62159/web_entrypoint.dart.lib.js:33:29)
at main.next ()
at http://localhost:62159/dart_sdk.js:39201:33
at _RootZone.runUnary (http://localhost:62159/dart_sdk.js:39058:58)
at _FutureListener.thenAwait.handleValue (http://localhost:62159/dart_sdk.js:34044:29)
at handleValueCallback (http://localhost:62159/dart_sdk.js:34604:49)
at Function._propagateToListeners (http://localhost:62159/dart_sdk.js:34642:17)
at _Future.new.[_completeWithValue] (http://localhost:62159/dart_sdk.js:34484:23)
at http://localhost:62159/dart_sdk.js:33695:46
at _RootZone.runUnary (http://localhost:62159/dart_sdk.js:39058:58)
at _FutureListener.then.handleValue (http://localhost:62159/dart_sdk.js:34044:29)
at handleValueCallback (http://localhost:62159/dart_sdk.js:34604:49)
at Function._propagateToListeners (http://localhost:62159/dart_sdk.js:34642:17)
at _Future.new.[_completeWithValue] (http://localhost:62159/dart_sdk.js:34484:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:62159/dart_sdk.js:34507:35)
at Object._microtaskLoop (http://localhost:62159/dart_sdk.js:39345:13)
at _startMicrotaskLoop (http://localhost:62159/dart_sdk.js:39351:13)
at http://localhost:62159/dart_sdk.js:34858:9

asn1lib >=1.20 fails to decode snmp message sequences (tag 162) which causes dart_snmp to timeout

Hi there,
I am facing a request time out issue. Below is the code I am using

    var target = InternetAddress('192.168.0.1');
    var session = await Snmp.createSession(target);
    var oid = Oid.fromBytes(ASN1OctetString('1.3.6.1.2.1.1.1.0').encodedBytes);
    var message;
    try {
      message = await session.get(oid);
    } catch (e) {
      print(e);
    }

Output:

    Snmp v2c session initialized.
    Bound to target 0.0.0.0 on port 52912
    Exception: Request to 192.168.0.1:161 timed out

When I try to connect with the same IP from the terminal I am able to get the data but not via flutter (dart_snmp).
What should I do to fix it ?

Wrong return value :(

hi there :)
i have an issue

this is my code

void GitOid() async {
    var target = InternetAddress('10.11.104.7');
    var session = await Snmp.createSession(
      target,
      port: 161,
      community: "private123",
    );
    var oid = Oid.fromString('1.3.6.1.4.1.2011.6.128.1.1.2.43.1.3.4194315520.25');
    // sysDesc
    var message = await session.get(oid); 

    print(message.pdu.varbinds[0].value); // outputs system description

  }

This function should return

1.3.6.1.4.1.2011.6.128.1.1.2.43.1.3.4194315520.25: 485754433236cc37
Object Name: 1.3.6.1.4.1.2011.6.128.1.1.2.43.1.3.4194315520.25 (iso.3.6.1.4.1.2011.6.128.1.1.2.43.1.3.4194315520.25)
Value (OctetString): 485754433236cc37

*note i get this value on the same request from wireshark .

but the function return

Base64 value
SFdUQzI2zDc=

and when i decode it the value become

HWTC267

This value is not totally wrong , but it is not the full value that I want from the function to return. It should be like this:
HWTC3236CC37

and it is the same value the ont have it on the user side that look like this

485754433236cc37

and i test this on OLT GPON the old version on snmp v2c protocol

what can i do to fix this issue ?

Exception is thown inside lib code. "Future already completed"

Whenever a get/set request error occurs, an extra error is shown in the console:

E/flutter (10010): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Bad state: Future already completed
E/flutter (10010): #0      _AsyncCompleter.complete (dart:async/future_impl.dart:45:31)
E/flutter (10010): #1      Request.complete (package:dart_snmp/src/models/request.dart:45:17)
E/flutter (10010): #2      Snmp._onEvent (package:dart_snmp/src/snmp_base.dart:156:36)

I will be opening a pull request for this fix in a few minutes.

Exception: Snmp Pdu Error on 1.3.6.1.2.1.43.5.1.1.17.1: NotWritable

Hello,
I was using your library to be able to communicate with printers present locally on the network. I use a public MIB to be able to retrieve the information, I am given the OctetString, but it does not print any other information about the printer because it gives, on a machine, this exception: Exception: Snmp Pdu Error on 1.3.6.1.2.1.43.5.1.1. 17.1: NotWritable. In the other machine, this exception: Exception: Snmp Pdu Error on 1.3.6.1.2.1.43.5.1.1.17.1: NoAccess.

Consider that for me it is the first time that I have to deal with this protocol.

Thanks

Set BITS type

Hi.

Do you have any example of how to send a SET for BITS type?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.