为什么在运行应用程序时显示端口错误?



E/flutter (5985): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: SocketException: OS ERROR: Connection timed out, errno = 110, address = 10.153.192.23, port = 42423

通常该错误意味着套接字端口被防火墙关闭,或者该端口上没有可以接受您的连接的侦听器。你能张贴一些代码异常发生?也许只是端口错了。(即。互联网上的每个套接字连接都基于IP地址和端口,端口是标识服务侦听位置的数字)

// this is the function which send a json packet to endpoint service.
Future<http.Response> _sendItalPostePacket(UploadBarcodeData data){
developer.log("UploadManager: _sendItalPostePacket");
developer.log("UploadManager: ${data.dump()}");
developer.log("UploadManager: ${jsonEncode(data.toJson())}");
String item='['+jsonEncode(data.toJson())+']';// here i add brackets because the server aspect list of strings ot only one.
return http.post(
endpoint,//** here is the URL of service endpoint**
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body:item, // here is the JSON
);
}
// this class provide the function toJson to encode all class items in a json string
class UploadBarcodeData
{
int ID ;                             //progressivo nella sincronizzazione
String IDGruppo ;                    //identificativo del gruppo di poste
String Codice ;                      //codice letto
String DataLettura ;               //data in cui è stata effettuata la lettura
double LatX ;                        //latitudine (obbligatoria)
double LatY ;                        //longitudine (obbligatoria)
String IdEsito ;                     //identificativo del tipo di esitazione registrata
bool IsSync ;                        //booleano che indica se sincronizzione ok
String Image ;                       //stringa che contiene il base64 dell'immagine
Position position;
UploadBarcodeData({this.Codice,this.DataLettura,this.position}){
ID=1;
IDGruppo = "cfb5b2de-c967-4d3f-b688-c6a15de15daa";
IdEsito = "f4256e8c-cfca-49ee-bb60-a52a5f0ab2a3";
Image="";
IsSync=false;
LatX=position.latitude;
LatY=position.longitude;
}
@override
void initState() {
}

Map<String,dynamic> toJson()=>{
'ID':ID,
'IDGruppo':IDGruppo,
'Codice':Codice,
'DataLettura':DataLettura,
'LatX':LatX,
'LatY':LatY,
'IdEsito':IdEsito,
'IsSync':IsSync,
'Image':Image,
};
toString(){
return Codice;
}
@override
String dump(){
developer.log("UploadBarcodeData: ${toJson().toString()}");
return toJson().toString();
}
}

相关内容

最新更新