Comments (27)
@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.
I replaced 'localhost' with my notebook's IP and released the port used in the firewall
from flutter-redux-starter.
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.
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.
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.
Dear I have this problem in my flutter app - when connect strapi with mongodb
SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 44128this 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:
from flutter-redux-starter.
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.
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.
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.
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.
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.
Glad to hear it's working, thanks for sharing the fix!
from flutter-redux-starter.
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.
Maybe the info here will help... flutter/flutter#11444
from flutter-redux-starter.
Thanks for sharing the solution!
from flutter-redux-starter.
I replaced 'localhost' with my notebook's IP and released the port used in the firewall
You are so good!
from flutter-redux-starter.
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.
@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.
If you have the answers in near future then please answer this Question here...!
from flutter-redux-starter.
@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.
@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.
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.
@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.
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.
@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.
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.
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.
from flutter-redux-starter.
Related Issues (20)
- Automatically run Dart formatter to clean up the code HOT 8
- Fix URL issues with slashes or dashes
- Remove -e backup files created by sed on macOS HOT 4
- Use built_value for view models/enable StoreConnector.distinct
- Port shell script to source_gen (maybe?)
- XXX has stoped HOT 10
- Invalid argument(s): Unknown type on deserialization. Need either specifiedType or discriminator field HOT 8
- Installation fails due to `http` package dependency HOT 8
- How to implement Login functionality HOT 1
- Use Relative Paths instead of fully qualified. HOT 3
- TODO comments fix HOT 2
- Login Functions HOT 2
- How to run the script in windows OS? HOT 1
- Couldn't clone hacker_news or posts HOT 2
- confusion when field is 'id'
- model .g file not create while i create new module with command HOT 2
- Exception has occurred. SocketException (SocketException: OS Error: Connection refused, errno = 111, address = 127.0.0.1, port = 53424)
- Add active/deleted state filter
- Set initial sort
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter-redux-starter.