Closed ram-sh closed 5 years ago
I get the same exception. I was using working code. but todey I get this exception.
Are you able to get what IP Address it's trying to use? What does Socket.OSSupportsIPv6 return? What OS are you running on?
I suspect it's IPv6, and your computer doesn't support it. Answering the above question may shed some light on that theory.
public TcpTransport(string address, int port, TcpClientConnectionHandler handler = null)
{
if (handler == null)
{
var ipAddress = IPAddress.Parse(address);
var endpoint = new IPEndPoint(ipAddress, port);
_tcpClient = new TcpClient(endpoint);
_tcpClient.Connect(endpoint);
}
else
_tcpClient = handler(address, port);
}
I get an ip adress like 149.134.145.100:443 I m using win10.
the exception is in TcpTransport.cs file and in this line _tcpClient = new TcpClient(endpoint);
is it just us? everyone else doesn't have this error?
@eordukaya can you be more specific? do you get 149.134.145.100:443
in the address
variable? including the colon and the port?
after this statement I get exception var endpoint = new IPEndPoint(ipAddress, port); I looked endpoint and variable is 149.134.145.100:443
@eordukaya I didn't ask you to look at ipAddress
variable but to address
variable.
Anyway, seems correct. Can you revert commit 3224113e4ce827319c049f44ee5a759ad1591fa0
and tell us if it connects successfully to the same IP address?
I update this commit but get exception again in this line.
That's not a proper revert, you're creating a TcpClient instance twice. Do git revert 3224113e4ce827319c049f44ee5a759ad1591fa0
instead of doing it manually.
Ok I understand. I download fixed TLSharp with 3224113e4ce827319c049f44ee5a759ad1591fa0 . But I get exception again. I added my debug photos.
Man, you're not reverting the commit I'm telling you. If you see a variable endpoint
in the code, then it means you're not testing what I'm telling you. You're just testing latest master.
@knocte , had the same problem, reverting your suggested commit 3224113e4ce827319c049f44ee5a759ad1591fa0
fixed the issue.
@byguid and what's the IP address that you connected and tried to connect (when not reverting)? Same?
@knocte, yes, the address was the same in both cases.
@ram-sh @knocte I reverted code block in edited file (for IPv6) TcpTransport.cs I deleted this block;
if (handler == null) { var ipAddress = IPAddress.Parse(address); var endpoint = new IPEndPoint(ipAddress, port); _tcpClient = new TcpClient(endpoint); _tcpClient.Connect(endpoint); } else _tcpClient = handler(address, port);
I added this block instead of before
if (handler == null) { _tcpClient = new TcpClient(); var ipAddress = IPAddress.Parse(address); _tcpClient.Connect(ipAddress, port); } else _tcpClient = handler(address, port);
Then it works.
@CloneDeath so apparently your commit broke this, did you test it?
@CloneDeath @knocte if commit works on ipV6, can be done; if ipv6 use new else use old then you can new commit.
But @CloneDeath's patch was supposed to work with both, we checked in the MSDN documentation.
ok, I reported that old version works but new doesnt. @CloneDeath can check again. thanks for everything.
@eordukaya solution worked for me as well! thanks much!!
This issue is duplicate of https://github.com/sochix/TLSharp/issues/862 , which has just been fixed.
Hello,
using TLSharp 0.1.0.390
app crash at create new TelegramClient object :(
Unhandled Exception: System.Net.Sockets.SocketException: The requested address is not valid in its context at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at System.Net.Sockets.TcpClient..ctor(IPEndPoint localEP) at TLSharp.Core.Network.TcpTransport..ctor(String address, Int32 port, TcpClientConnectionHandler handler) at TLSharp.Core.TelegramClient..ctor(Int32 apiId, String apiHash, ISessionStore store, String sessionUserId, TcpClientConnectionHandler handler)
what is it i'm missing here?
thank you in advance!!