Difference between revisions of "ActiveSockets"

From aHuman Wiki
Jump to: navigation, search
(Automated page entry using MWPush.pl)
 
(Automated page entry using MWPush.pl)
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
+
<pre style="color: green">Network Listeners</pre>
#summary Network Listeners
+
@@[[Home]] -> [[Specs]] -> [[ActiveSockets]]
@@[[Home]] -> [Specs] -> [ActiveSockets]
+
 
----
 
----
  
Line 15: Line 14:
 
* inbound stream can be forwarded to configured IO channel
 
* inbound stream can be forwarded to configured IO channel
 
* stream from specific IO channel can be forwarded to outbound
 
* stream from specific IO channel can be forwarded to outbound
* active socket supports protocol configuring - see [[MediaProtocols Protocols]]
+
* active socket supports protocol configuring - see [[MediaProtocols|Protocols]]
 
* if forwarding inbound stream - creates thread to read from socket and automatically reconnects if connection was broken
 
* if forwarding inbound stream - creates thread to read from socket and automatically reconnects if connection was broken
  
 
Planned but implemented:
 
Planned but implemented:
* to have non-persisting connections - to use active connection only after request from server, do not restore connection automatically
+
* to have non-persisting connections - to use active connection only after request from server, do not restore connection automatically  
 
* timeout for reconnection
 
* timeout for reconnection
  
Line 25: Line 24:
  
 
* sample configuration for google active socket in media.xml
 
* sample configuration for google active socket in media.xml
{{{
+
<pre>
<channel name="google" run="true">
+
<channel name="google" run="true">
<property name="protocol" value="http"/>
+
<property name="protocol" value="http"/>
<property name="protocol.showmessages" value="false"/>
+
<property name="protocol.showmessages" value="false"/>
<property name="protocol.showpackets" value="false"/>
+
<property name="protocol.showpackets" value="false"/>
<property name="msgtype" value="text"/>
+
<property name="msgtype" value="text"/>
<property name="permanent" value="true"/>
+
<property name="permanent" value="true"/>
<property name="host" value="www.google.com"/>
+
<property name="host" value="www.google.com"/>  
<property name="port" value="80"/>
+
<property name="port" value="80"/>  
<property name="redirect-in" value="true"/>
+
<property name="redirect-in" value="true"/>
<property name="redirect-out" value="true"/>
+
<property name="redirect-out" value="true"/>  
<property name="topic-in" value="http.response"/>
+
<property name="topic-in" value="http.response"/>  
<property name="topic-out" value="http.request"/>
+
<property name="topic-out" value="http.request"/>  
</channel>
+
</channel>
}}}
+
</pre>
  
* *host* - host to connect to - now IP-addresses are not supported
+
* '''host''' - host to connect to - now IP-addresses are not supported  
* *port* - port to connect to
+
* '''port''' - port to connect to
* *redirect-in* - if "true" then messages are forwarded from socket to IO channel
+
* '''redirect-in''' - if "true" then messages are forwarded from socket to IO channel
* *redirect-out* - if "true" then messages are forwarded from IO channel to socket
+
* '''redirect-out''' - if "true" then messages are forwarded from IO channel to socket
* *topic-in* - channel to write messages received from socket
+
* '''topic-in''' - channel to write messages received from socket
* *topic-out* - messages from this channel are sent to socket - see [[MediaProtocols Protocols]]
+
* '''topic-out''' - messages from this channel are sent to socket - see [[MediaProtocols|Protocols]]
* *reconnectionTimeout* - if unable to connect to socket, then next attempt is performed only after reconnectionTimeout seconds
+
* '''reconnectionTimeout''' - if unable to connect to socket, then next attempt is performed only after reconnectionTimeout seconds
  
 
== How to Test ==
 
== How to Test ==
  
 
* use google active socket and test to read some page:
 
* use google active socket and test to read some page:
{{{
+
<pre>
 
INFO: AI console
 
INFO: AI console
 
INFO: connected to 87.228.126.111:20001
 
INFO: connected to 87.228.126.111:20001
 
REQUEST:
 
REQUEST:
 
<xmlcall name="TestDirectChannels-Google" class="TestDirectChannels" method="testRequestPage" requestId="REQ-1">
 
<xmlcall name="TestDirectChannels-Google" class="TestDirectChannels" method="testRequestPage" requestId="REQ-1">
<parameters>
+
    <parameters>
<property name="page" value="http://code.google.com" />
+
        <property name="page" value="http://code.google.com" />
</parameters>
+
    </parameters>
 
</xmlcall>
 
</xmlcall>
  
Line 65: Line 64:
 
RESPONSE:
 
RESPONSE:
 
<xmlcallresult requestId="REQ-1" name="TestDirectChannels-Google" status="OK">
 
<xmlcallresult requestId="REQ-1" name="TestDirectChannels-Google" status="OK">
<page>http://code.google.com</page>
+
    <page>http://code.google.com</page>
<body>&lt;!DOCTYPE html... (omitted)
+
    <body>&lt;!DOCTYPE html... (omitted)
 
</xmlcallresult>
 
</xmlcallresult>
  
 
INFO: disconnected
 
INFO: disconnected
 +
</pre>

Latest revision as of 18:51, 28 November 2018

Network Listeners

@@Home -> Specs -> ActiveSockets


Overview

This feature allows to have unlimited set of connections initiated from aiengine server to external servers.

Implementation Details

  • aiengine creates all active sockets on startup
  • active socket is available via AIMedia interface
  • active socket is available via IO channels if configured
  • inbound stream can be forwarded to configured IO channel
  • stream from specific IO channel can be forwarded to outbound
  • active socket supports protocol configuring - see Protocols
  • if forwarding inbound stream - creates thread to read from socket and automatically reconnects if connection was broken

Planned but implemented:

  • to have non-persisting connections - to use active connection only after request from server, do not restore connection automatically
  • timeout for reconnection

Configuration

  • sample configuration for google active socket in media.xml
		<channel name="google" run="true">
			<property name="protocol" value="http"/>
			<property name="protocol.showmessages" value="false"/>
			<property name="protocol.showpackets" value="false"/>
			<property name="msgtype" value="text"/>
			<property name="permanent" value="true"/>
			<property name="host" value="www.google.com"/> 
			<property name="port" value="80"/> 
			<property name="redirect-in" value="true"/>
			<property name="redirect-out" value="true"/> 
			<property name="topic-in" value="http.response"/> 
			<property name="topic-out" value="http.request"/> 
		</channel>
  • host - host to connect to - now IP-addresses are not supported
  • port - port to connect to
  • redirect-in - if "true" then messages are forwarded from socket to IO channel
  • redirect-out - if "true" then messages are forwarded from IO channel to socket
  • topic-in - channel to write messages received from socket
  • topic-out - messages from this channel are sent to socket - see Protocols
  • reconnectionTimeout - if unable to connect to socket, then next attempt is performed only after reconnectionTimeout seconds

How to Test

  • use google active socket and test to read some page:
INFO: AI console
INFO: connected to 87.228.126.111:20001
REQUEST:
<xmlcall name="TestDirectChannels-Google" class="TestDirectChannels" method="testRequestPage" requestId="REQ-1">
    <parameters>
        <property name="page" value="http://code.google.com" />
    </parameters>
</xmlcall>

output:
RESPONSE:
<xmlcallresult requestId="REQ-1" name="TestDirectChannels-Google" status="OK">
    <page>http://code.google.com</page>
    <body><!DOCTYPE html... (omitted)
</xmlcallresult>

INFO: disconnected