Raised This Month: $4 Target: $400
 1% 

Module: Threaded Sockets


Post New Thread Reply   
 
Thread Tools Display Modes
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 11-22-2020 , 13:40   Re: Module: Threaded Sockets
Reply With Quote #71

Quote:
Originally Posted by wopox3 View Post
Having the same problem. Using binaries from 1st post.
Code:
Linux 38a4062eab23 5.4.39-linuxkit #1 SMP Fri May 8 23:03:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
Maybe there was some update with Linux after 5years ^^' Implemented Appveyor Autobuild and Possible fix in #c18088a. Try Latest build and please check if it fixes the issue. Release and Debug versions connote the same as previously specified in readme.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 11-22-2020 at 13:44.
Shooting King is offline
wopox3
Junior Member
Join Date: Dec 2013
Location: Russia
Old 11-22-2020 , 17:23   Re: Module: Threaded Sockets
Reply With Quote #72

same result. reported at issue
wopox3 is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 11-23-2020 , 12:10   Re: Module: Threaded Sockets
Reply With Quote #73

Quote:
Originally Posted by wopox3 View Post
same result. reported at issue
Which version of AMXX/Metamod are you using wopox ? can you help me with "meta list", "amxx modules" and how are you getting such detailed messages about unable to find symbols in AMXX Log ? Are you using the debug project or release ?

Also Try installing the 1st post .so's + install pthreads on your system. For ubuntu, it must be some, "apt-get install pthreads-xxx" (my guess: apt-get install libpthread-stubs0-dev)'.

I can successfully load original attached module in 1st post, without an error on Ubuntu 20.04.1 LTS.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 11-23-2020 at 20:27.
Shooting King is offline
wopox3
Junior Member
Join Date: Dec 2013
Location: Russia
Old 11-23-2020 , 22:25   Re: Module: Threaded Sockets
Reply With Quote #74

I'm added more info to Github Issue #2.
wopox3 is offline
karaulov
Senior Member
Join Date: Jul 2018
Old 11-28-2020 , 00:52   Re: Module: Threaded Sockets
Reply With Quote #75

I can't use VK API via threaded sockets??


Code:
#include <amxmodx>
#include <sockets>

new g_iThreadHandle;
new lasttime = 0;
public plugin_init()
{
	register_plugin( "needadmin", "1.0", "needadmin" );
	register_concmd( "say /needadmin" , "TestCmd" ); 

}

public TestCmd(id)
{
	if ( time() - lasttime > 60 )
	{
		lasttime = time()
		g_iThreadHandle = socket_create_t();
		if((socket_open_t(g_iThreadHandle, "api.vk.com", 80, SOCKET_TCP, "CBOpenSocket")) < 0 )
		{
			log_amx( "ERROR: Could not open Socket." );
			return;
		}
		log_amx( "Trying to open connection..." );
	}
	else 
	{
		client_print(id, print_console, "ERROR! PLEASE WAIT 60 SECONDS")
	}
}

public CBOpenSocket( iThreadState, iReturn )
{
	if( iReturn < 0 )
	{
		log_amx( "ERROR: Could not open Socket. Error[%d] : %d", iReturn, socket_get_last_error_t(g_iThreadHandle) );
	}
	else
	{        
		new szPacket[1024]; 

		formatex( szPacket, 1023, 
		"%s%i%s%s%s", "GET /method/messages.send?access_token=123123123ACCESSTOCKEN123123123123&v=5.124&peer_id=2000000001&message=[SERVER%%20CS%%201.6%%20]%%20IGROKI%%20PROSIAT%%20ADMINOV%%20ZAITI%%20NA%%20SERVER&random_id=", lasttime," HTTP/1.0^r^n","Host: api.vk.com^r^n","Content-Type: text/plain^r^n^r^n");

		log_amx( "Socket Opened. Trying to send Data..." );
		log_amx( szPacket );
		if((socket_send_t( g_iThreadHandle, szPacket, sizeof(szPacket), "CBSendSocket")) < 0 )
		{
			log_amx( "ERROR: Could not Send data." );
		}
	}
}

public CBSendSocket( iThreadState, iReturn )
{
	if( iReturn < 0 )
	{
		log_amx( "ERROR: Error Sending Data. Error[%d] : %d", iReturn, socket_get_last_error_t(g_iThreadHandle) );
	}
	else
	{
		socket_close_t(g_iThreadHandle, "CBCloseSocket");
	}
}

public CBCloseSocket( iThreadState, iReturn )
{
	if( iReturn == 0 )
	{
		log_amx( "Socket Closed. Destroying Thread." );
		socket_destroy_t(g_iThreadHandle);
	}
	else
	{
		log_amx( "Error Closing socket.  Errno : %d", socket_get_last_error_t(g_iThreadHandle) );
	}
}
In log i see

Code:
GET /method/messages.send?access_token=123123123ACCESSTOCKEN123123123123&v=5.124&peer_id=2000000001&message=[SERVER%20CS%201.6%20]%20IGROKI%20PROSIAT%20ADMINOV%20ZAITI%20NA%20SERVER&random_id=1606538861 HTTP/1.0
Host: api.vk.com
Content-Type: text/plain
But in group i can't see these messages!

Last edited by karaulov; 11-28-2020 at 00:52.
karaulov is offline
karaulov
Senior Member
Join Date: Jul 2018
Old 11-28-2020 , 04:50   Re: Module: Threaded Sockets
Reply With Quote #76

Tried to install latest build, but got:

Code:
L 11/28/2020 - 11:47:01: [AMXX] Module "cstrike/addons/amxmodx/modules/sockets_amxx_i386.so" failed to load (cstrike/addons/amxmodx/modules/sockets_amxx_i386.so: undefined symbol: _ZdlPvj)
L 11/28/2020 - 11:47:01: Error:
L 11/28/2020 - 11:47:01: [AMXX] Module is not a valid library (file "cstrike/addons/amxmodx/modules/sockets_amxx_i386.so")
karaulov is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 11-28-2020 , 09:05   Re: Module: Threaded Sockets
Reply With Quote #77

Quote:
Originally Posted by karaulov View Post
I can't use VK API via threaded sockets??


Code:
#include <amxmodx>
#include <sockets>

new g_iThreadHandle;
new lasttime = 0;
public plugin_init()
{
	register_plugin( "needadmin", "1.0", "needadmin" );
	register_concmd( "say /needadmin" , "TestCmd" ); 

}

public TestCmd(id)
{
	if ( time() - lasttime > 60 )
	{
		lasttime = time()
		g_iThreadHandle = socket_create_t();
		if((socket_open_t(g_iThreadHandle, "api.vk.com", 80, SOCKET_TCP, "CBOpenSocket")) < 0 )
		{
			log_amx( "ERROR: Could not open Socket." );
			return;
		}
		log_amx( "Trying to open connection..." );
	}
	else 
	{
		client_print(id, print_console, "ERROR! PLEASE WAIT 60 SECONDS")
	}
}

public CBOpenSocket( iThreadState, iReturn )
{
	if( iReturn < 0 )
	{
		log_amx( "ERROR: Could not open Socket. Error[%d] : %d", iReturn, socket_get_last_error_t(g_iThreadHandle) );
	}
	else
	{        
		new szPacket[1024]; 

		formatex( szPacket, 1023, 
		"%s%i%s%s%s", "GET /method/messages.send?access_token=123123123ACCESSTOCKEN123123123123&v=5.124&peer_id=2000000001&message=[SERVER%%20CS%%201.6%%20]%%20IGROKI%%20PROSIAT%%20ADMINOV%%20ZAITI%%20NA%%20SERVER&random_id=", lasttime," HTTP/1.0^r^n","Host: api.vk.com^r^n","Content-Type: text/plain^r^n^r^n");

		log_amx( "Socket Opened. Trying to send Data..." );
		log_amx( szPacket );
		if((socket_send_t( g_iThreadHandle, szPacket, sizeof(szPacket), "CBSendSocket")) < 0 )
		{
			log_amx( "ERROR: Could not Send data." );
		}
	}
}

public CBSendSocket( iThreadState, iReturn )
{
	if( iReturn < 0 )
	{
		log_amx( "ERROR: Error Sending Data. Error[%d] : %d", iReturn, socket_get_last_error_t(g_iThreadHandle) );
	}
	else
	{
		socket_close_t(g_iThreadHandle, "CBCloseSocket");
	}
}

public CBCloseSocket( iThreadState, iReturn )
{
	if( iReturn == 0 )
	{
		log_amx( "Socket Closed. Destroying Thread." );
		socket_destroy_t(g_iThreadHandle);
	}
	else
	{
		log_amx( "Error Closing socket.  Errno : %d", socket_get_last_error_t(g_iThreadHandle) );
	}
}
In log i see

Code:
GET /method/messages.send?access_token=123123123ACCESSTOCKEN123123123123&v=5.124&peer_id=2000000001&message=[SERVER%20CS%201.6%20]%20IGROKI%20PROSIAT%20ADMINOV%20ZAITI%20NA%20SERVER&random_id=1606538861 HTTP/1.0
Host: api.vk.com
Content-Type: text/plain
But in group i can't see these messages!
What you are doing seems correct but, after writing Socket for HTTP Request, dont close the socket, Keep "Reading the socket", you will get a HTTP response code, and some error data/success data from api.vk.com. You can check what has gone wrong from that.

As per the undefined symbol, its on-going issue, you can use binaries attached in this thread's 1st post, which are working.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
karaulov
Senior Member
Join Date: Jul 2018
Old 11-29-2020 , 06:05   Re: Module: Threaded Sockets
Reply With Quote #78

Impossible to add backward compatibility with previous module versions?



And possible error in code, because send function send two requests instead of one?

RECV RETURN NEXT LINES:

Code:
L 11/28/2020 - 23:48:28: [myarenaapi.amxx] RECV:HTTP/1.1 200 OK
Server: nginx
Date: Sat, 28 Nov 2020 20:48:26 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=20
Access-Control-Allow-Origin: *
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=63072000; includeSubdomains; preload

2ac
{"status":"OK","data":{"b":{"type":"halflife","ip":"0.0.0.0","c_port":27015,"q_port":27015,"s_port":27015,"status":1},"s":{"game":"cstrike","name":"Server name","map":"de_dust2","players":1,"playersmax":32,"password":0},"p":[{"pid":0,"name":""Player name","score":0,"time":"00:18:31"}],"t":[]},"online":1,"server_id":"525","server_name":"Counter-Strike 1.6","server_address":"0.0.0.027015","server_maxslots":0,"server_location":"Moscow","server_type":"1 x Core i7 8700K OC, 2.5Gb RAM, 40Gb NVME","server_dateblock":"1609408607","server_daystoblock":33}
0

HTTP/1.1 400 Bad Request
Server: nginx/1.12.2
Date: Sat, 28 Nov 2020 20:48:26 GMT
Content-Type: text/html
Content-Length: 173
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.12.2</center>
</body>
</html>
Got two responses in one recv function!
And how to make RECV read all data (pass 0 or -1 to 'length' arg)?

Last edited by karaulov; 11-29-2020 at 06:09.
karaulov is offline
karaulov
Senior Member
Join Date: Jul 2018
Old 11-29-2020 , 15:23   Re: Module: Threaded Sockets
Reply With Quote #79

Please also fix these problems in code https://github.com/ShootingKing-AM/T...ckets/issues/6 (possible crash in Windows, memory leak, and bad variable name)
karaulov is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 11-30-2020 , 10:25   Re: Module: Threaded Sockets
Reply With Quote #80

Quote:
Originally Posted by karaulov View Post
Impossible to add backward compatibility with previous module versions?
backward compatibility is always there, if you are finding something which is not working as intended, report to me.
Quote:
Originally Posted by karaulov View Post
And possible error in code, because send function send two requests instead of one?
Send function sends only one req per invocation.
Quote:
Originally Posted by karaulov View Post
RECV RETURN NEXT LINES:

Code:
L 11/28/2020 - 23:48:28: [myarenaapi.amxx] RECV:HTTP/1.1 200 OK
Server: nginx
Date: Sat, 28 Nov 2020 20:48:26 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Keep-Alive: timeout=20
Access-Control-Allow-Origin: *
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=63072000; includeSubdomains; preload

2ac
{"status":"OK","data":{"b":{"type":"halflife","ip":"0.0.0.0","c_port":27015,"q_port":27015,"s_port":27015,"status":1},"s":{"game":"cstrike","name":"Server name","map":"de_dust2","players":1,"playersmax":32,"password":0},"p":[{"pid":0,"name":""Player name","score":0,"time":"00:18:31"}],"t":[]},"online":1,"server_id":"525","server_name":"Counter-Strike 1.6","server_address":"0.0.0.027015","server_maxslots":0,"server_location":"Moscow","server_type":"1 x Core i7 8700K OC, 2.5Gb RAM, 40Gb NVME","server_dateblock":"1609408607","server_daystoblock":33}
0

HTTP/1.1 400 Bad Request
Server: nginx/1.12.2
Date: Sat, 28 Nov 2020 20:48:26 GMT
Content-Type: text/html
Content-Length: 173
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx/1.12.2</center>
</body>
</html>
Got two responses in one recv function!
Please read the documentation properly, RECV will be called that many times the server sends the data, if you want to get only one packet, keep a local packetcounter and close the socket.

Quote:
Originally Posted by karaulov View Post
And how to make RECV read all data (pass 0 or -1 to 'length' arg)?
RECV handler will be called until everything is read, if the data recv'd is 100bytes and your one time buffer is 10 bytes, RECV handler will be called 10 times per one data reception.

Also, Put up issue on Alliedmodders OR Github, dont keep bumping the thread, dont post the same issue twice.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:44.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode