Forum Discussion
break long tcp connection
rule testrule1 {
when CLIENT_ACCEPTED {
set count 0
TCP::collect
}
when CLIENT_DATA {
incr count
log local0. "count $count"
if { $count == 2} {
set count 0
log local0. "before select nod 11 $count"
LB::detach
use node "192.168.2.11" 80
log local0. "node 11 was selected, count $count"
TCP::release
} else {
LB::detach
log local0. "before select pool0 $count"
pool web_pool
TCP::release
}
}
But when I tried this rule to virtual server, there is no traffic was sent to node.
I just made reference to the irule that break IIOP application to do this, but because these is no document to explain how to use TCP::collect, TCP::release, I can not figure out why my rule can not work.
BTW, in the irule of breaking IIOP, event USER_REQUEST and USER_RESPONSE were used, what they are used for?
when USER_REQUEST {
if {$c_req_id == 1} {
set c_req_id 0
persist add uie $req_id
}
if {$c_is_cancel == 1} {
set c_is_cancel 0
LB::detach
}
}
when USER_RESPONSE {
LB::detach
}
}
Thank you for reply in advance.
/**
class:SocketTest_SvrClit
author:chengyun
date:
with:to test socket---client program;
**/
import java.net.*;
import java.io.*;
public class SocketTest_SvrClit
{
public static void main(String[] args) throws UnknownHostException,IOException,ConnectException
{
Socket aClient=null;
aClient=new Socket("192.168.0.188",3434); //InetAddress.getLocalHost()
try
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
BufferedReader in=new BufferedReader(new InputStreamReader(aClient.getInputStream()));
PrintWriter out=new PrintWriter(new OutputStreamWriter(aClient.getOutputStream()));
String clientString=null;
String serverString=null;
int i=1;
System.out.println("hello!enter bye to exit.");
boolean done=false;
serverString="start";
while(!done)
{
if (i==1000) i=1;
Thread.sleep(1000);
//serverString=in.readLine();
if(serverString !=null)
System.out.println("Server:"+serverString);
System.out.print("client:");
//clientString=input.readLine();
clientString=Integer.toString(i++);
if(clientString.equals("bye")) done=true;
if(clientString !=null)
{
out.println(clientString);
out.flush();
}
serverString=in.readLine();
}
in.close();
out.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
finally
{
aClient.close();
}
}
}
--------------
/**
class:SocketTest_SvrClit
author:chengyun
date:
with:to test socket---server program;
**/
import java.net.*;
import java.io.*;
public class SocketTest_Server
{
public static void main(String[] args) throws UnknownHostException,IOException,ConnectException
{
ServerSocket aServerSocket=new ServerSocket(3434);
Socket aServer=null;
try
{
aServer=aServerSocket.accept();
try
{
BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
BufferedReader in=new BufferedReader(new InputStreamReader(aServer.getInputStream()));
PrintWriter out=new PrintWriter(new OutputStreamWriter(aServer.getOutputStream()));
String serverstring=null;
String clientstring=null;
System.out.println("hello! enter the bye to exit.");
System.out.print("Server:wait client");
serverstring=input.readLine();
boolean done=false;
while(!done)
{
if(serverstring !=null)
{
out.println(serverstring);
out.flush();
}
clientstring=in.readLine();
if(clientstring !=null)
System.out.println("client:"+clientstring);
System.out.print("server:");
//serverstring=input.readLine();
serverstring="server:"+clientstring;
if(serverstring.equals("bye")) done=true;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
finally
{
aServer.close();
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
finally
{
aServerSocket.close();
}
}
}
Great thanks! I needed to run a bash command but I decided to go with "util/bash" API endpoint (https://community.f5.com/t5/technical-forum/running-bash-commands-via-rest-api/td-p/272516 ) but now I know I can also run bash commands from a tmsh script 🙂
The only thing with such scripts is how to see the real output when using API:
curl -sku admin:niki@111 https://10.1.1.130/mgmt/tm/cli/script/niki -H "Content-Type: application/json"
Output API:
{"kind":"tm:cli:script:scriptstate","name":"niki","fullPath":"niki","generation":7832,"selfLink":"https://localhost/mgmt/tm/cli/script/niki?ver=16.1.3.2","apiAnonymous":"proc script::init {} {\n}\n\nproc script::run {} {\nreturn [tmsh::list ltm pool]\n}\n\nproc script::help {} {\n}\n\nproc script::tabc {} {\n}\n","ignoreVerification":"false","totalSigningStatus":"not-all-signed","verificationStatus":"none"}Output CLI:
root@(bigip2)(cfg-sync Standalone)(Active)(/Common)(tmos)# run cli script niki
ltm pool Fake-ICAP-pool {
members {
1.1.1.1:icap {
address 1.1.1.1
}
}Script:
root@(bigip2)(cfg-sync Standalone)(Active)(/Common)(tmos)# edit cli script niki
modify script niki {
proc script::init {} {
}proc script::run {} {
puts [tmsh::list ltm pool]
}proc script::help {} {
}proc script::tabc {} {
}