GithubHelp home page GithubHelp logo

Comments (27)

jiangzhixiao avatar jiangzhixiao commented on July 28, 2024 266

@hillelcoren, a big mistake... i set kApiUrl='localhost:8888/api',the problem is "localhost"
actually "localhost" should be replaced to "10.0.2.2"
If you run AVD(Client)/spring boot(Server) ,in same computer, you have to set the kApiUrl to "10.0.2.2:port/api"
thanks again !

from flutter-redux-starter.

ricardocrescenti avatar ricardocrescenti commented on July 28, 2024 25

I replaced 'localhost' with my notebook's IP and released the port used in the firewall

from flutter-redux-starter.

hawarih avatar hawarih commented on July 28, 2024 16

Dear I have this problem in my flutter app - when connect strapi with mongodb
SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 44128

this is my code for registerpage

 http.Response response = await http.post(
      'http://localhost:1337/auth/local/register',
     body:{"username": _username, "email": _email, "password": _password});

     final responseData = json.decode(response.body);
     setState(() => _isSubmitting = true);
     _showSuccessSnack();
     _redirectUser();
     print(responseData);
   } 

any one have idea how to solve this

from flutter-redux-starter.

kuyu132 avatar kuyu132 commented on July 28, 2024 8

under mac you need set the ip 0.0.0.0, then mac will show the firewall dialog, press agree, then you can access the mock server in your LAN

from flutter-redux-starter.

hillelcoren avatar hillelcoren commented on July 28, 2024 6

I'm not sure... a comment here suggests adding an "accept:application/json" header may help.

The relevant code is here: https://github.com/hillelcoren/flutter-redux-starter/blob/master/lib/data/web_client.dart#L10

You may also want to try using telnet to confirm you can connect to the host/port.

from flutter-redux-starter.

sagarshende23 avatar sagarshende23 commented on July 28, 2024 6

Dear I have this problem in my flutter app - when connect strapi with mongodb
SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 44128

this is my code for registerpage

 http.Response response = await http.post(
      'http://localhost:1337/auth/local/register',
     body:{"username": _username, "email": _email, "password": _password});

     final responseData = json.decode(response.body);
     setState(() => _isSubmitting = true);
     _showSuccessSnack();
     _redirectUser();
     print(responseData);
   } 

any one have idea how to solve this

Found the Solution: If you're running the server locally and using the Android emulator, then your server endpoint should be 10.0.2.2:8000 instead of localhost:8000 as AVD uses 10.0.2.2 as an alias to your host loopback interface (i.e) localhost

**'http://10.0.2.2:1337/auth/local/register',**

clear explanation checkout this Answer:

stackoverflow.com/questions/60001536/flutter-socketexception-socketexception-os-error-connection-refused-errno

from flutter-redux-starter.

Majid110 avatar Majid110 commented on July 28, 2024 6

You can forward 8888 port from AVD to host computer by running this command:
adb reverse tcp:8888 tcp:8888

and now localhost:8888 is accessible.

Also that port (8888) must allowed in firewall Inbound Rules.

from flutter-redux-starter.

Chaitanyaha avatar Chaitanyaha commented on July 28, 2024 3

What should be the host link if I want to run the application on my physical phone?
Also how would things work if I upload the application on google play store what would be the host link then?

from flutter-redux-starter.

macelux avatar macelux commented on July 28, 2024 3

What should be the host link if I want to run the application on my physical phone?
Also how would things work if I upload the application on google play store what would be the host link then?

Any solution to this?

from flutter-redux-starter.

sagarshende23 avatar sagarshende23 commented on July 28, 2024 2

What should be the host link if I want to run the application on my physical phone?
Also how would things work if I upload the application on google play store what would be the host link then?
yeah the Same Question comes to my mind right Now!!!

from flutter-redux-starter.

josed1608 avatar josed1608 commented on July 28, 2024 1

Just found the problem. Turns out the the sockJs configuration on the Spring STOMP endpoint caused the http upgrade request made by Flutter to not match the expected format on the server side. My server has to work for both an Angular web app and a Flutter mobile app so I guess I'll just have two websocket endpoints, one for web and the other for mobile. I was also missing a 0 byte at the end of the body of the STOMP frame, so that was also messing things up.

Thanks for the reference to the issue, it helped a lot in diagnosing the problem.

from flutter-redux-starter.

hillelcoren avatar hillelcoren commented on July 28, 2024

Glad to hear it's working, thanks for sharing the fix!

from flutter-redux-starter.

josed1608 avatar josed1608 commented on July 28, 2024

Hey, I've been trying to connect to connect to my Spring WebSockets (they use STOMP) but when i try to connect with IOWebSocketChannel I get the exception:
WebSocketChannelException: WebSocketChannelException: WebSocketException: Connection to 'http://10.1.137.147:8080/ws#' was not upgraded to websocket

Did you encounter this issue?

from flutter-redux-starter.

hillelcoren avatar hillelcoren commented on July 28, 2024

Maybe the info here will help... flutter/flutter#11444

from flutter-redux-starter.

hillelcoren avatar hillelcoren commented on July 28, 2024

Thanks for sharing the solution!

from flutter-redux-starter.

YuanTianyang avatar YuanTianyang commented on July 28, 2024

I replaced 'localhost' with my notebook's IP and released the port used in the firewall

You are so good!

from flutter-redux-starter.

julianrodri11 avatar julianrodri11 commented on July 28, 2024

En mi caso tenia montado mi pagina web en wordpress de forma local con xampp, para consumir la api rest de wordpress con flutter, además mire este vídeo, muy bueno:

https://www.youtube.com/watch?v=IaNOJD07aKU&t=26s.

Pero tuve que detener cuando me salio el
errno 111: aparecía el error por colocar localhost o 127.0.0.1 en la http, estaba diciendo que la pagina web estaba montada en el celular cuando la aplicación se abría, y no era así por que el servicio estaba en el pc, entonces debía sacar la ip por donde el pc tenia internet en mi caso por wifi, y colocar esa ip, ademas si se tenia un puerto diferente habilitar la entrada y salida por las reglas de firewall.
final respuesta = await http.get( 'http://127.0.0.1:90/word/wp-json/wp/v2/pages?_embed', headers: {"Accept": "application/json"});

Antes de eso me cruce con el errno 7: se debía a que celular no tenia activado el wifi además debían estar conectado a la misma red wifi tanto el portátil como el celular.

Al final:
El celular y el portátil debían estar en el mismo wifi
Desde el portátil se debía crear una regla de firewall de entrada y salida en mi caso por el puerto 90
Se debía verificar desde el navegador del celular, que se pudiera acceder al servicio api rest local montado en wordpress asi:
http://192.168.0.104:90/word/wp-json/wp/v2/pages?_embed
Si había respuesta entonces se iba a mostrar los parámetros solicitados cuando se corra la aplicación en el celular.

Mas fácil aun era usar un api rest wordpress publico o con ip publica como este:
https://virtuooza.com/wp-json/wp/v2/posts?_embed
para ver si la aplicación que se desarrollo en el vídeo funcionaba correctamente para hacer pruebas y así luego consumir nuestros propios servicios.

Código final.
`import 'package:http/http.dart' as http;
import 'dart:convert';

Future fetchWpPosts() async {
final respuesta = await http.get(
'http://192.168.0.104:90/word/wp-json/wp/v2/pages?_embed ',
headers: {"Accept": "application/json"});
var datosConvertidosJson = jsonDecode(respuesta.body);
return datosConvertidosJson;
}
`

from flutter-redux-starter.

0xjoaovpsantos avatar 0xjoaovpsantos commented on July 28, 2024

@hillelcoren, a big mistake... i set kApiUrl='localhost:8888/api',the problem is "localhost"
actually "localhost" should be replaced to "10.0.2.2"
If you run AVD(Client)/spring boot(Server) ,in same computer, you have to set the kApiUrl to "10.0.2.2:port/api"
thanks again !

Thank you!!!!!!!!!!!!!!!!!!!!!

from flutter-redux-starter.

Chaitanyaha avatar Chaitanyaha commented on July 28, 2024

If you have the answers in near future then please answer this Question here...!

from flutter-redux-starter.

emmanuelNono avatar emmanuelNono commented on July 28, 2024

@hillelcoren , une grosse erreur ... j'ai mis kApiUrl = 'localhost: 8888 / api', le problème est "localhost" en
fait "localhost" devrait être remplacé par "10.0.2.2"
Si vous exécutez AVD (Client) / spring boot (Serveur), dans le même ordinateur, vous devez régler le kApiUrl sur "10.0.2.2:port/api"

tu es génial

from flutter-redux-starter.

MuhammadNizamani avatar MuhammadNizamani commented on July 28, 2024

@hillelcoren, a big mistake... i set kApiUrl='localhost:8888/api',the problem is "localhost"
actually "localhost" should be replaced to "10.0.2.2"
If you run AVD(Client)/spring boot(Server) ,in same computer, you have to set the kApiUrl to "10.0.2.2:port/api"
thanks again !

how can I change localhost to 10.0.0.2

from flutter-redux-starter.

MuhammadNizamani avatar MuhammadNizamani commented on July 28, 2024

I am using Genymotion and i am trying to connect flutter with python through flask but when I run my app and send a request to API I got a connection refused error. kindly help how to solve the problem.

from flutter-redux-starter.

caseyryan avatar caseyryan commented on July 28, 2024

@hillelcoren, a big mistake... i set kApiUrl='localhost:8888/api',the problem is "localhost"
actually "localhost" should be replaced to "10.0.2.2"
If you run AVD(Client)/spring boot(Server) ,in same computer, you have to set the kApiUrl to "10.0.2.2:port/api"
thanks again !

You don't even know how much nerves your reply saved me :D I wish you a great day!

from flutter-redux-starter.

Urvish24 avatar Urvish24 commented on July 28, 2024

If you done all thing perfect then try to put some delay to call the fuction
It Work Perfect for me

from flutter-redux-starter.

okinawaa avatar okinawaa commented on July 28, 2024

@hillelcoren, a big mistake... i set kApiUrl='localhost:8888/api',the problem is "localhost" actually "localhost" should be replaced to "10.0.2.2" If you run AVD(Client)/spring boot(Server) ,in same computer, you have to set the kApiUrl to "10.0.2.2:port/api" thanks again !

you save my life

from flutter-redux-starter.

IncognitoGK9 avatar IncognitoGK9 commented on July 28, 2024

Exception has occurred.
SocketException (SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = localhost, port = 44198) for using real device with emulator. On the configuration, I have passed the actual ip address of the host (192.168.43.81 which is in the same wi-fi network with the actual real device on iP: 192.168.43.1 and on the firebase json file, am using 0.0.0.0 to have full broadcast.

NOTE: this is flutter + Dart + firebase emulators + Real device (on others, android emulator, or web, it is working fine) - I need to use real device.

What could be wrong?

from flutter-redux-starter.

EufranioDiogo avatar EufranioDiogo commented on July 28, 2024

We(myself and my girlfriend) was running a Android Phone (Not emulator) and we was using a WebService on our local server on the same network with Android Phone, but the error was in the port of our local server, it was not open.

In our local server running Ubuntu 22.04.2 LTS.

sudo ufw allow <SERVER_PORT>

You can search how to open a port in your OS and see if it works for you.

for Linux:
https://www.digitalocean.com/community/tutorials/opening-a-port-on-linux#for-ubuntu-users-and-ufw-based-systems

for MacOS:https://www.macworld.com/article/671729/mac-firewall-how-to-open-specific-ports-in-os-x-10-10-firewall.html

for Windows:
https://learn.microsoft.com/en-us/sql/reporting-services/report-server/configure-a-firewall-for-report-server-access?view=sql-server-ver16

from flutter-redux-starter.

Related Issues (20)

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.