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

EINTR: The operation was interrupted #36

Open
Zqiang12345 opened this issue Mar 20, 2024 · 10 comments
Open

EINTR: The operation was interrupted #36

Zqiang12345 opened this issue Mar 20, 2024 · 10 comments

Comments

@Zqiang12345
Copy link

On Android, I use
socket.send(result);
socket.recv();
An error will be reported
E/flutter (18544): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ZeroMQException(4): EINTR: The operation was interrupted
E/flutter (18544): #0 _checkErrorCode (package:dartzmq/src/exception.dart:56:5)
E/flutter (18544): #1 _checkReturnCode (package:dartzmq/src/exception.dart:49:5)
E/flutter (18544): #2 ZSyncSocket.recv (package:dartzmq/src/socket.dart:406:9)
E/flutter (18544): #3 _FirmwareBodyWidgetState._sendNextMessage (package:healthy_voice/ui/config/firmware_version.dart:179:18)

on ios socket.recv(); Cannot set timeout

when i use
socket.messages.listen((message) {
print('Received: $message');
// _sendNextMessage();
});

An error will be reported
E/flutter (18544): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ZeroMQException(156384763): Operation cannot be accomplished in current state
E/flutter (18544): #0 _checkErrorCode (package:dartzmq/src/exception.dart:56:5)
E/flutter (18544): #1 _checkReturnCode (package:dartzmq/src/exception.dart:49:5)
E/flutter (18544): #2 ZContext._poll (package:dartzmq/src/zeromq.dart:109:9)
E/flutter (18544): #3 ZContext._startPolling. (package:dartzmq/src/zeromq.dart:68:70)
E/flutter (18544): #4 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter (18544): #5 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter (18544): #6 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

@enwi
Copy link
Owner

enwi commented Mar 20, 2024

Could it be that you are sending a null message? According to this EINTR is thrown for a null message.

@Zqiang12345
Copy link
Author

Could it be that you are sending a null message? According to this EINTR is thrown for a null message.

I'm going to abandon the synchronous method if I have data, but I get an error when I use asynchronous listening

E/flutter (18544): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ZeroMQException(156384763): Operation cannot be accomplished in current state
E/flutter (18544): #0 _checkErrorCode (package:dartzmq/src/exception.dart:56:5)
E/flutter (18544): #1 _checkReturnCode (package:dartzmq/src/exception.dart:49:5)
E/flutter (18544): #2 ZContext._poll (package:dartzmq/src/zeromq.dart:109:9)
E/flutter (18544): #3 ZContext._startPolling. (package:dartzmq/src/zeromq.dart:68:70)
E/flutter (18544): #4 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter (18544): #5 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter (18544): #6 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

@Zqiang12345
Copy link
Author

I'm using the req/rep mode

@enwi
Copy link
Owner

enwi commented Mar 21, 2024

Please use a dealer socket instead of the req socket when using the async socket

@Zqiang12345
Copy link
Author

Please use a dealer socket instead of the req socket when using the async socket

When I used the sync mode, ios worked properly and Android reported an error as I mentioned above, and I couldn't set the timeout period, which would cause the program to get stuck

@Zqiang12345
Copy link
Author

Could it be that you are sending a null message? According to this EINTR is thrown for a null message.

We have data. ios is working fine

@Zqiang12345
Copy link
Author

                            socket.send(result);
                            Future.delayed(Duration(milliseconds: 1000),(){
                              final message = socket.recv();
                              print("getMessage $message");
                            });

I don't seem to have real synchronization on Android. I need to delay the recv() method to receive the data. If I call recv() directly, I get an error "EINTR: The operation was interrupted ", which is probably what you mean by null date because I'm not receiving data

@enwi
Copy link
Owner

enwi commented Mar 23, 2024

I think we must ignore the EINTR like it is done for the async sockets

_checkReturnCode(rc, ignore: [EAGAIN, EINTR]);

Can you try adding that ignore?

@Zqiang12345
Copy link
Author

I think we must ignore the EINTR like it is done for the async sockets

_checkReturnCode(rc, ignore: [EAGAIN, EINTR]);

Can you try adding that ignore?

I am very sorry for not replying to your message in time. I used ^1.0.0-dev.17 with _checkReturnCode(rc, ignore: [EAGAIN, EINTR]); But this error still occurs. Have you not repeated this error ?

@enwi
Copy link
Owner

enwi commented Mar 25, 2024

I haven't tested it myself yet

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

No branches or pull requests

2 participants