SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 06/10/2017, 03:56 PM   #291
Kaperstone
High-roller
 
Kaperstone's Avatar
 
Join Date: May 2011
Location: Russia
Posts: 3,353
Reputation: 822
Default Re: Socket plugin (v0.2b released)

Quote:
Originally Posted by Omirrow View Post
None else haven't had this problem before?
Encountered the same issue on a clean setup, wondered why 0.2b ain't loading, even tho I had it in my dir/
Code:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team

[18:55:11] 
[18:55:11] Server Plugins
[18:55:11] --------------
[18:55:11]  Loading plugin: crashdetect
[18:55:11]   CrashDetect v4.18.1 is OK.
[18:55:11]   Loaded.
[18:55:11]  Loading plugin: socket02b
[18:55:11]   Failed.
[18:55:11]  Loaded 1 plugins.

[18:55:11] 
[18:55:11] Filterscripts
[18:55:11] ---------------
[18:55:11]   Loaded 0 filterscripts.

[18:55:11] [debug] Run time error 19: "File or function is not found"
[18:55:11] [debug]  socket_create
[18:55:11] [debug]  is_socket_valid
[18:55:11] [debug]  socket_connect
[18:55:11] [debug]  socket_set_max_connections
[18:55:11] [debug]  socket_listen
[18:55:11] [debug]  socket_destroy
[18:55:11] [debug]  socket_send
[18:55:11] [debug] Run time error 19: "File or function is not found"
[18:55:11] [debug]  socket_create
[18:55:11] [debug]  is_socket_valid
[18:55:11] [debug]  socket_connect
[18:55:11] [debug]  socket_set_max_connections
[18:55:11] [debug]  socket_listen
[18:55:11] [debug]  socket_destroy
[18:55:11] [debug]  socket_send
[18:55:11] Script[gamemodes/socket.amx]: Run time error 19: "File or function is not found"
[18:55:11] Number of vehicle models: 0

----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team

[18:55:19] 
[18:55:19] Server Plugins
[18:55:19] --------------
[18:55:19]  Loading plugin: crashdetect
[18:55:19]   CrashDetect v4.18.1 is OK.
[18:55:19]   Loaded.
[18:55:19]  Loading plugin: socket01b
[18:55:19]  Socket plugin v0.1b loaded.
[18:55:19]   Loaded.
[18:55:19]  Loaded 2 plugins.

[18:55:19] 
[18:55:19] Filterscripts
[18:55:19] ---------------
[18:55:19]   Loaded 0 filterscripts.

[18:55:20] socket_connect(): Socket ID 0 has failed to connect.
[18:55:20] socket_listen(): Socket has failed to bind on port 7776.
[18:55:20] Socket Test Gamemode main
[18:55:20] Number of vehicle models: 0
__________________
Kaperstone is offline   Reply With Quote
Old 16/10/2017, 09:09 AM   #292
Shaneisace
Big Clucker
 
Join Date: Jan 2012
Posts: 83
Reputation: 18
Default Re: Socket plugin (v0.2b released)

Quote:
Originally Posted by Kaperstone View Post
Encountered the same issue on a clean setup, wondered why 0.2b ain't loading, even tho I had it in my dir/
Code:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team

[18:55:11] 
[18:55:11] Server Plugins
[18:55:11] --------------
[18:55:11]  Loading plugin: crashdetect
[18:55:11]   CrashDetect v4.18.1 is OK.
[18:55:11]   Loaded.
[18:55:11]  Loading plugin: socket02b
[18:55:11]   Failed.
[18:55:11]  Loaded 1 plugins.

[18:55:11] 
[18:55:11] Filterscripts
[18:55:11] ---------------
[18:55:11]   Loaded 0 filterscripts.

[18:55:11] [debug] Run time error 19: "File or function is not found"
[18:55:11] [debug]  socket_create
[18:55:11] [debug]  is_socket_valid
[18:55:11] [debug]  socket_connect
[18:55:11] [debug]  socket_set_max_connections
[18:55:11] [debug]  socket_listen
[18:55:11] [debug]  socket_destroy
[18:55:11] [debug]  socket_send
[18:55:11] [debug] Run time error 19: "File or function is not found"
[18:55:11] [debug]  socket_create
[18:55:11] [debug]  is_socket_valid
[18:55:11] [debug]  socket_connect
[18:55:11] [debug]  socket_set_max_connections
[18:55:11] [debug]  socket_listen
[18:55:11] [debug]  socket_destroy
[18:55:11] [debug]  socket_send
[18:55:11] Script[gamemodes/socket.amx]: Run time error 19: "File or function is not found"
[18:55:11] Number of vehicle models: 0

----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.7-R2, (C)2005-2015 SA-MP Team

[18:55:19] 
[18:55:19] Server Plugins
[18:55:19] --------------
[18:55:19]  Loading plugin: crashdetect
[18:55:19]   CrashDetect v4.18.1 is OK.
[18:55:19]   Loaded.
[18:55:19]  Loading plugin: socket01b
[18:55:19]  Socket plugin v0.1b loaded.
[18:55:19]   Loaded.
[18:55:19]  Loaded 2 plugins.

[18:55:19] 
[18:55:19] Filterscripts
[18:55:19] ---------------
[18:55:19]   Loaded 0 filterscripts.

[18:55:20] socket_connect(): Socket ID 0 has failed to connect.
[18:55:20] socket_listen(): Socket has failed to bind on port 7776.
[18:55:20] Socket Test Gamemode main
[18:55:20] Number of vehicle models: 0
It can't be the plugin it works fine, do you have microsoft visuals and all that?

My O/S: Windows 10 (Works fine on Centos 7 also)

Code:
 Socket plugin v0.2b loaded.
  Loaded.
[Socket]: Connection listening on IP: 127.0.0.1 | port 7780.
Shaneisace is offline   Reply With Quote
Old 06/12/2017, 09:34 PM   #293
PawnoQ
Huge Clucker
 
Join Date: Nov 2011
Posts: 381
Reputation: 7
Question Re: Socket plugin (v0.2b released)

can someone tell me if the callback
PHP Code:
public onSocketRemoteDisconnect(Socket:idremote_clientid
is working properly?
Seems like this one is never getting called on the server when i close the socket connection at the client side.

Is is working for you guys?
If so, what do i have to do on client side so this callback gets called?


thanks!
PawnoQ is offline   Reply With Quote
Old 13/12/2017, 05:08 PM   #294
PawnoQ
Huge Clucker
 
Join Date: Nov 2011
Posts: 381
Reputation: 7
Question Re: Socket plugin (v0.2b released)

Hi,

i have an issue with this plugin.
The server seems to close connections to the connected clients randomly (gmx/restart of the server is not triggered)

This is my pawn code where i bind and listen for connections/data:
Code:
#include <a_samp>
#include <socket>

new Socket:CLIENT_SOCKET;
#define SOCKET_PORT 7785
#define SOCKET_MAX_CONNECTION 25

new connected_remote_clients;

public OnGameModeInit()
{
	new ip[16];
	GetServerVarAsString("bind", ip, sizeof (ip));
	
	connected_remote_clients=0;
	
	CLIENT_SOCKET = socket_create(TCP);
	if(is_socket_valid(CLIENT_SOCKET))
	{
	    socket_set_max_connections(CLIENT_SOCKET, SOCKET_MAX_CONNECTION);
	    socket_bind(CLIENT_SOCKET, ip);
		socket_listen(CLIENT_SOCKET, SOCKET_PORT);
	}
	return 1;
}

public OnGameModeExit()
{
	if(is_socket_valid(CLIENT_SOCKET))socket_destroy(CLIENT_SOCKET);
	return 1;
}

public onSocketRemoteConnect(Socket:id, remote_client[], remote_clientid)
{
    connected_remote_clients++;
	return 1;
}

public onSocketReceiveData(Socket:id, remote_clientid, data[], data_len)
{
	print(data);
	SendSocketMessageToAllClients(data);
	return 1;
}

public OnPlayerText(playerid, text[])
{
    SendSocketMessageToAllClients(text);
	return 1;
}

forward SendSocketMessageToAllClients(socket_message[]);
public SendSocketMessageToAllClients(socket_message[])
{
    for(new client_i=0; client_i<connected_remote_clients; client_i++)
    {
	    if(is_socket_valid(CLIENT_SOCKET))socket_sendto_remote_client(CLIENT_SOCKET, client_i, socket_message);
	}
	return 1;
}

I made an app (=client) that connects to the server chat.
Works just fine.
BUT, from time to time (totally random it seems), i get this error message on the client side:
PHP Code:
[Errno 10054An existing connection was forcibly closed by the remote host
Seems like the server randomly closes the conenction to my clients?
Can you give me a hint where to look for the bug?
Or is it another bug by the plugin, an issue you already know about?

Someone experienced this before?
Im running this on linux.

Thank you!
PawnoQ is offline   Reply With Quote
Old 13/12/2017, 10:46 PM   #295
Kaperstone
High-roller
 
Kaperstone's Avatar
 
Join Date: May 2011
Location: Russia
Posts: 3,353
Reputation: 822
Default Re: Socket plugin (v0.2b released)

Quote:
Originally Posted by PawnoQ View Post
Hi,

i have an issue with this plugin.
The server seems to close connections to the connected clients randomly (gmx/restart of the server is not triggered)

This is my pawn code where i bind and listen for connections/data:
Code:
#include <a_samp>
#include <socket>

new Socket:CLIENT_SOCKET;
#define SOCKET_PORT 7785
#define SOCKET_MAX_CONNECTION 25

new connected_remote_clients;

public OnGameModeInit()
{
	new ip[16];
	GetServerVarAsString("bind", ip, sizeof (ip));
	
	connected_remote_clients=0;
	
	CLIENT_SOCKET = socket_create(TCP);
	if(is_socket_valid(CLIENT_SOCKET))
	{
	    socket_set_max_connections(CLIENT_SOCKET, SOCKET_MAX_CONNECTION);
	    socket_bind(CLIENT_SOCKET, ip);
		socket_listen(CLIENT_SOCKET, SOCKET_PORT);
	}
	return 1;
}

public OnGameModeExit()
{
	if(is_socket_valid(CLIENT_SOCKET))socket_destroy(CLIENT_SOCKET);
	return 1;
}

public onSocketRemoteConnect(Socket:id, remote_client[], remote_clientid)
{
    connected_remote_clients++;
	return 1;
}

public onSocketReceiveData(Socket:id, remote_clientid, data[], data_len)
{
	print(data);
	SendSocketMessageToAllClients(data);
	return 1;
}

public OnPlayerText(playerid, text[])
{
    SendSocketMessageToAllClients(text);
	return 1;
}

forward SendSocketMessageToAllClients(socket_message[]);
public SendSocketMessageToAllClients(socket_message[])
{
    for(new client_i=0; client_i<connected_remote_clients; client_i++)
    {
	    if(is_socket_valid(CLIENT_SOCKET))socket_sendto_remote_client(CLIENT_SOCKET, client_i, socket_message);
	}
	return 1;
}

I made an app (=client) that connects to the server chat.
Works just fine.
BUT, from time to time (totally random it seems), i get this error message on the client side:
PHP Code:
[Errno 10054An existing connection was forcibly closed by the remote host
Seems like the server randomly closes the conenction to my clients?
Can you give me a hint where to look for the bug?
Or is it another bug by the plugin, an issue you already know about?

Someone experienced this before?
Im running this on linux.

Thank you!
In that case you should just reconnect, the error means that one of your connection is timing out because it been idle for too long while the other one tries to use that connection.


I haven't used the plugin yet in production, but on whether side it happens I'd suggest to reconnect automatically to not fall between the chairs.

Quote:
Originally Posted by PawnoQ View Post
can someone tell me if the callback
PHP Code:
public onSocketRemoteDisconnect(Socket:idremote_clientid
is working properly?
Seems like this one is never getting called on the server when i close the socket connection at the client side.

Is is working for you guys?
If so, what do i have to do on client side so this callback gets called?


thanks!
It works properly.

It calls when the samp server is already running and listening for a connection and you try to connect with your other application.

I don't receive this connection when its the other way around, but the application(not the plugin) does show a message that it has established a connection.

EDIT: haven't noticed that you meant the onremotesocketdisconnect, right when I remembered that I wanted to note that it doesn't call for a strange reason, but the connect works fine.

I am using 0.1b, but 0.2b might contain a bug fix that fixes this issue.
__________________
Kaperstone is offline   Reply With Quote
Old 14/12/2017, 06:29 PM   #296
PawnoQ
Huge Clucker
 
Join Date: Nov 2011
Posts: 381
Reputation: 7
Thumbs up Re: Socket plugin (v0.2b released)

Ok, thank you so much for your input!

Is there a way to set up a TCP Socket/Connection that will not timeout like that?
In case not, would it be a good idea to send a little bit of random data through that connection (lets say every 30 seconds) to prevent the connection to timeout?

Also what i dont understand: Does this plugin when sending messages implement a kinda protocol?
Like how does it know when (when receiving a data stream) the message is complete and the next message
is coming in?
Does the plugin seperate the messages with a NULL Byte or another delimiter?
Cause i code an app that receives the data stream sent by the server and i have a hard time at the client side
to seperate messages atm.

Can you point me into the right direction on this one?

Last edited by PawnoQ; 14/12/2017 at 07:15 PM.
PawnoQ is offline   Reply With Quote
Old 15/12/2017, 06:13 AM   #297
Kaperstone
High-roller
 
Kaperstone's Avatar
 
Join Date: May 2011
Location: Russia
Posts: 3,353
Reputation: 822
Default Re: Socket plugin (v0.2b released)

Quote:
Originally Posted by PawnoQ View Post
Ok, thank you so much for your input!

Is there a way to set up a TCP Socket/Connection that will not timeout like that?
In case not, would it be a good idea to send a little bit of random data through that connection (lets say every 30 seconds) to prevent the connection to timeout?

Also what i dont understand: Does this plugin when sending messages implement a kinda protocol?
Like how does it know when (when receiving a data stream) the message is complete and the next message
is coming in?
Does the plugin seperate the messages with a NULL Byte or another delimiter?
Cause i code an app that receives the data stream sent by the server and i have a hard time at the client side
to seperate messages atm.

Can you point me into the right direction on this one?
It will be generally a good idea to send bits of little data to know the latency and if the connection is still alive.

I don't know if that would prevent the connection from closing up and I think it's better to have it that way, when the connection closes and opens again, many databases reset the connections and web connections does this as well, so I think it would be good to follow that path as well.

About the protocol, it doesn't implement a new protocol, there are only two protocols: UDP and TCP, you use either of them, the difference between them is that UDP sends the information and whether the other side received it, it doesn't care.

on TCP, it sends a packet, the other side receives that and sends a packet back saying "I received your message"
UDP is generally a lot better than TCP if you implement a game, because the data always changes and never the same and you don't care if the other side had received your packets, don't forget that TCP still needs to wait for approval of receiving this message, means its stored in RAM, a game would be a very resource expensive if TCP is implemented.

On the other hand, TCP would be nice if you want to ensure that the data you've sent is received, like chats, if you don't want one of the sides to have a missing message, then you can implement a TCP.

More about the functioning
https://en.wikipedia.org/wiki/Transm...twork_function

About whether it knows when a message is being received, from my personal knowledge, it kind of not and kind of does.

TCP can open a connection and hold onto it and you can freely exchange data through the open connection, while UDP doesn't allow it, you send data and you forget about it.

When the server starts to listen for sockets, it awaits for any socket be received at any time, when the a new socket is being received, it receives the ACK flags first, exchanges them and only then received the socket data itself.

UDP I only guess, doesn't exchange data, as it only sends data, whatever the target machines received, it received.




About how the messages are being separated I don't know.
I personally use an njs stream, I had a problem with the socket being delivered all together.
I guess it depends on the programming language that you use.

I also had them as one, I just waited for a processtick to occur, and sent them.
As for receiving sockets from the plugin, I never had issue with the messages.
__________________
Kaperstone is offline   Reply With Quote
Old 16/12/2017, 12:13 AM   #298
PawnoQ
Huge Clucker
 
Join Date: Nov 2011
Posts: 381
Reputation: 7
Thumbs up Re: Socket plugin (v0.2b released)

Thanks a lot for all your effort!
Helped me a lot!

And also it seems that sending some random data from time to time is fixing my 'timeout' issue.


thank you!



EDIT:
BTW, the function:
Code:
native socket_remote_client_connected(Socket:id, remote_clientid); // tcp only
crashes the server. (tested on linux).

Last edited by PawnoQ; 16/12/2017 at 12:46 AM.
PawnoQ is offline   Reply With Quote
Old 07/01/2018, 08:33 PM   #299
PawnoQ
Huge Clucker
 
Join Date: Nov 2011
Posts: 381
Reputation: 7
Default Re: Socket plugin (v0.2b released)

Sorry for double post, but was wondering if someone of you guys using this plugin experienced crashes?
Seems like this plugin randomly causes the server to crash from time to time.
Someone of you experienced issues on linux before?
PawnoQ is offline   Reply With Quote
Old 07/01/2018, 10:38 PM   #300
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,530
Reputation: 326
Default Re: Socket plugin (v0.2b released)

Quote:
Originally Posted by PawnoQ View Post
Sorry for double post, but was wondering if someone of you guys using this plugin experienced crashes?
Seems like this plugin randomly causes the server to crash from time to time.
Someone of you experienced issues on linux before?
Come to think of it i did have problems but it might also be related to the sleep param in server.cfg so... my crashes stopped when i removed socket, improved the script and made the sleep param 3
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link




Code:
You may only contact me through the links on my signature, if else then its an impersonating one, i am not on any other place not mentioned in my signature.
RogueDrifter is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Socket Plugin] Retrieving input stream iRage Scripting Help 0 08/01/2014 09:11 AM
Question about socket plugin Kirollos Scripting Help 6 13/07/2012 08:33 PM


All times are GMT. The time now is 01:54 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.