android socket econnrefused,android - Socket connecting : ECONNREFUSED - Stack Overflow

I am used the below code to connect to a php websocket.

serverAddr = InetAddress.getByName(ip_str);

socket = new Socket(serverAddr, port_str);

mBufferIn = new BufferedReader(new InputStreamReader(socket.getInputStream()));

Trying to open a socket and want to listen to what data is coming from the server.

the ip_str is something like this : wss://xyz.com:8181/game where xyz is the actual host name, and 8181 is a dummy port number(have given dummy values as i cannot give the actual values here - but it is working fine on web as we are trying to connect same socket via web).

On this line :

socket = new Socket(serverAddr, port_str);

I am getting the following error message :

java.net.ConnectException: failed to connect to ip6-localhost/::1 (port 8181): connect failed: ECONNREFUSED (Connection refused)

Anyone has any idea why i am facing this issue?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值