Can't connect from flutter app to remote meteor server - flutter

I need to get data for flutter apps from a remote meteor server. Connecting locally to the local host and receiving data packets, and connecting to a remote server gives an error. I am consuming dart_meteor.
I/flutter (23037): MeteorClient[426707093] - Make a connection to wss://example.com/websocket
I/flutter (23037): WebSocketException: Connection to 'https://example.com:0/websocket#' was not upgraded to websocket
Code snippet for connection.
MeteorClient meteor = MeteorClient.connect(url: 'https://example.com');
void main() => runApp(MyApp());

Related

Flutter Unhandled Exception: SocketException: OS Error: Broken pipe, errno = 32, address = 10.0.2.2, port = 51420

I am using Flutter with Flask at back end. I want to send an image from flutter to Flask for processing.
enter image description here
But I am getting this error in Android studio:
[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: SocketException: OS Error: Broken pipe, errno = 32, address = 10.0.2.2, port = 51420
My flask terminal says:
127.0.0.1 - - [11/May/2021 23:07:56] "←[37mPOST / HTTP/1.1←[0m" 200 -
Your server process has received a SIGPIPE writing to a socket. This usually happens when you write to a socket fully closed on the other (client) side. This might be happening when a client program doesn't wait till all the data from the server is received and simply closes a socket (using close function).
In a C program you would normally try setting to ignore SIGPIPE signal or setting a dummy signal handler for it. In this case a simple error will be returned when writing to a closed socket. In your case a python seems to throw an exception that can be handled as a premature disconnect of the client.

Flutter webrtc Failed to set remote answer sdp

I am trying to connect two peer in flutter webrtc but i am getting below error.I am using firebase as a signalling server.
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Unable to RTCPeerConnection::setRemoteDescription: peerConnectionSetRemoteDescription(): WEBRTC_SET_REMOTE_DESCRIPTION_ERROR: Failed to set remote answer sdp: Called in wrong state: stable
I am using below code in listening to the changes in firebase
if (val['t'] == "ans") {
assert(isInitiator);
_peerCon.setRemoteDescription(
RTCSessionDescription(
val['sdp'],
val['tp'],
),
);
return;
}
One peer connection can only set one remote description.
You are trying to setRemoteDescription on a peer with an already established connection. That's why you getting this error.
Check this thread for more details:
Failed to set remote answer sdp: Called in wrong state: stable

Flutter - Socket.Connect() - SocketException: OS Error: Connection timed out

When I was working on debug mode (with "flutter run") by using my device (real), Socket.Connect() method doesn't work.
Also I would like to say that this Connect method is in "dart:io" library.
In shortly;
I opened a server (TCP) with Python.
I wrote the Flutter client like below to be able to connecting to the server in Python.
Future den() async {
print("Started");
Socket sock = await Socket.connect("192.168.0.159", 5431);
print("Done +++++++++++++++++++++++++"); }
However, I took a SocketError as Connection time out.
The error message I took:
E/flutter (17655): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.0.159, port = 43836
NOTE:
I tried to change the manifest file by adding INTERNET permission, but it is not working.
It was a strange problem, because there is no problem the code I shared. Windows Defender performed a rule to block to open a port as server. Hence, I started the server on my machine, however, I couldn't connect it from my Android device.
Maybe, the error code that is shown by Flutter isn't clear. If you took a error about socket programming for connection or binding, looking to Defender (or firewall) can be affective method. Unfortunately, as I was just starting to learn Flutter, I thought of checking out Defender afterwards.

problem with flutter and mongodb connection

import 'package:mongo_dart/mongo_dart.dart';
main() async{
Db db = new Db("mongodb://localhost:27017/workouts");
await db.open();
print("success ---------------------------------");
}
this symple code and dont connect, i dont know why.
this is the output:
Syncing files to device Android SDK built for x86...
Restarted application in 306ms.
E/flutter ( 5415): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 52206
E/flutter ( 5415): #0 _ConnectionManager._connect (package:mongo_dart/src/network/connection_manager.dart:23:5)
....
and more logs
¿some help? :(
solved ==> https://stackoverflow.com/a/55786011/12369361
due to use emulator I need to use 10.0.2.2 instead of localhost
I suppose that you have a local mongoDB server. If it is the case, you have to connect your local server and your android phone to the same network (through wifi).
Then get the IP of your local server and replacing localhost in your url with the IP you found.
If you can't, it is possible that your firewall is blocking your requests.

Issues with Flutter and Phoenix Channels

We're having some issues with our Flutter App and Pheonix Web Sockets. We know that the Backend is working properly, since the JavaScript client is fully functional. But with the Flutter app we can't connect to the server.
final socket = PhoenixSocket("ws://###.##/socket");
connectSocket() async {
await widget.socket.connect();
_channel = widget.socket.channel("test:lobby")
_channel.on("say", _say);
_channel.join();
}
One of the errors were gettig:
I/flutter ( 4227): WebSocket connection to ws://###.##:8080/socket?vsn=2.0.0 failed!: WebSocketException: Connection to 'http://###.##:8080/socket?vsn=2.0.0#' was not upgraded to websocket
On the client side we're using Phoenix Wings, the port and URL are correct.
Why does this keep happening?
Are there any other libraries for Flutter with Phoenix Interactions?
Is there a better documentation for phoenix_wings or for any other packages?
I had it working as
final socket = PhoenixSocket("ws://####.###/socket/websocket");
hth.