I'm having an issue when testing my FIX client against my FIX server. My client logs look like this and you can see that the connection is being reset and I'm trying to determine why.
FIX client logs:
<event> Created session
<event> Connecting to 127.0.0.1 on port 5001
2/1/2023 2:50:32 PM inf: [FixClient] ToAdmin: FIX.4.4:CLIENT->SERVER [98, 2], [108, 30]
<event> Connection succeeded
<event> Session reset: ResetOnLogon
2/1/2023 2:50:32 PM inf: [FixClient] ToAdmin: FIX.4.4:CLIENT->SERVER [98, 0], [108, 30], [141, Y]
<event> Session reset: ResetSeqNumFlag
<outgoing> 8=FIX.4.49=7335=A34=149=CLIENT52=20230201-14:50:32.20356=SERVER98=0108=30141=Y10=177
<event> Initiated logon request
<event> Session FIX.4.4:CLIENT->SERVER disconnecting: System.Net.Sockets.SocketException (54): Connection reset by peer
at QuickFix.SocketInitiatorThread.ReadSome(Byte[] buffer, Int32 timeoutMilliseconds)
at QuickFix.SocketInitiatorThread.Read()
2/1/2023 2:50:32 PM inf: [FixClient] OnLogout: FIX.4.4:CLIENT->SERVER
<event> Session reset: ResetOnDisconnect
Client:
SessionID sessionId = new SessionID("FIX.4.4", "CLIENT", "SERVER");
var logon = new QuickFix.FIX44.Logon {
EncryptMethod = new EncryptMethod(EncryptMethod.None),
HeartBtInt = new HeartBtInt(30)
};
Session.SendToTarget(logon, sessionId);
client.cfg:
[DEFAULT]
ConnectionType=initiator
ReconnectInterval=30
FileStorePath=store
FileLogPath=log
StartTime=00:00:00
EndTime=00:00:00
UseDataDictionary=Y
DataDictionary=./FIX/spec/FIX44.xml
SocketConnectHost=127.0.0.1
SocketConnectPort=5001
LogoutTimeout=5
ResetOnLogon=Y
ResetOnLogout=Y
ResetOnDisconnect=Y
[SESSION]
# inherit ConnectionType, ReconnectInterval and SenderCompID from default
BeginString=FIX.4.4
SenderCompID=CLIENT
TargetCompID=SERVER
HeartBtInt=30
server.cfg:
[DEFAULT]
ConnectionType=acceptor
SocketAcceptPort=5001
StartTime=00:00:00
EndTime=00:00:00
FileLogPath=log
UseDataDictionary=Y
ResetOnLogon=Y
ResetOnLogout=Y
ResetOnDisconnect=Y
[SESSION]
BeginString=FIX.4.4
SenderCompID=CLIENT
TargetCompID=SERVER
FileStorePath=store
DataDictionary=./FIX/spec/FIX44.xml
It is the CompIDs.
Server and client should have swapped CompIDs.
Server TargetCompID is Client SenderCompID and vice versa.
Related: What causes the "Disconnecting: Encountered END_OF_STREAM" session message in QuickFIX/J?
Related
when I use dotenv for hiding my password and username this error happens, but if I don't use dotenv the error disappears:
MongoServerError: bad auth : Authentication failed.
at Connection.onMessage (E:\my work\web development by zhankar\assignment\assignment-11-warehouse\warehouse-backend\node_modules\mongodb\lib\cmap\connection.js:203:30)
at MessageStream.<anonymous> (E:\my work\web development by zhankar\assignment\assignment-11-warehouse\warehouse-backend\node_modules\mongodb\lib\cmap\connection.js:63:60)
at MessageStream.emit (node:events:390:28)
at processIncomingData (E:\my work\web development by zhankar\assignment\assignment-11-warehouse\warehouse-backend\node_modules\mongodb\lib\cmap\message_stream.js:108:16)
at MessageStream._write (E:\my work\web development by zhankar\assignment\assignment-11-warehouse\warehouse-backend\node_modules\mongodb\lib\cmap\message_stream.js:28:9)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at MessageStream.Writable.write (node:internal/streams/writable:334:10)
at TLSSocket.ondata (node:internal/streams/readable:754:22)
at TLSSocket.emit (node:events:390:28) {
ok: 0,
code: 8000,
codeName: 'AtlasError',
[Symbol(errorLabels)]: Set(0) {}
}
You are likely using dotenv in the wrong way.
Show how are you passing the variables
Basically, this is a minimal example:
#.env file
username=john
password=alice
No spaces around the =
//server.js
require('dotenv')()
//that populates process.env
console.log(process.env.password, process.env.username)
So to be clear, your details are stored in the process.env object.
All of sudden I got the following error continuously for a select query.
Unable to enlist connection in transaction: enlistResource returns 'false'
This appears to be thrown from DBCP (https://commons.apache.org/proper/commons-dbcp/jacoco/org.apache.commons.dbcp2.managed/TransactionContext.java.html)
Essentially, this code calls javax.transaction.Transaction.enlistResource
Looking at the API, it says "Enlist the resource specified with the transaction associated with the target Transaction object. true if the resource was enlisted successfully; otherwise false."
I am still not clear why this exception thrown.
What is enlist the resource to transaction?
When enlist resource returns false? I mean when transaction will not be able to enlist the resource?
How to avoid this problem?
Tech Stack:
TomEE 7.0.4
JPA
MariaDB
Data source config:
<Resource id="jdbc/myDS" type="javax.sql.DataSource">
dataSourceCreator = tomcat
jtaManaged = true
driverClassName = ${jdbc.driver}
url = ${jdbc.url}
username = ${jdbc.username}
password = ${jdbc.password}
initialSize = 5
maxActive = 100
maxIdle = 10
minIdle = 5
maxWait = 30000
validationQuery = SELECT 1
testOnBorrow = false
testOnReturn = false
testWhileIdle = true
timeBetweenEvictionRunsMillis = 1800000
numTestsPerEvictionRun = 2
minEvictableIdleTimeMillis = 1800000
accessToUnderlyingConnectionAllowed = false
</Resource>
Stack Trace:
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Unable to enlist connection in transaction: enlistResource returns 'false'.
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:218) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:198) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$000(LoggingConnectionDecorator.java:58) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.prepareStatement(LoggingConnectionDecorator.java:250) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:133) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.prepareStatement(ConfiguringConnectionDecorator.java:139) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:133) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$RefCountConnection.prepareStatement(JDBCStoreManager.java:1642) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:122) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:513) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:493) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.sql.SelectImpl.prepareStatement(SelectImpl.java:480) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:421) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:392) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:427) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:93) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.kernel.QueryImpl$PackingResultObjectProvider.open(QueryImpl.java:2075) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:33) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1257) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1013) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:869) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:800) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:541) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:274) ~[openjpa-2.4.2.jar:2.4.2]
at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:290) ~[openjpa-2.4.2.jar:2.4.2]
Just had the same issue and digged a little more into my log file. Right before the first appearance of
enlistResource returns 'false'
I found a
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Checking further up and found a
WARNING [https-jsse-nio-8443-exec-1] org.apache.geronimo.transaction.manager.TransactionImpl.enlistResource Unable to enlist XAResource org.apache.openejb.resource.jdbc.managed.local.LocalXAResource#2ce72e5a, errorCode: 0
javax.transaction.xa.XAException: Count not turn off auto commit for a XA transaction
All this leaded me to a old post from tomee-openejb mailing list. So my recent tomee.xml configuration looked like that:
<Resource id="[Resourcename]" type="javax.sql.DataSource">
jdbcDriver = com.mysql.jdbc.Driver
jdbcUrl = jdbc:mysql://localhost:3306/[Databasename]
userName = [Username]
password = [Password]
</Resource>
Now I changed it to the following config:
<Resource id=[Name] type="javax.sql.DataSource">
jdbcDriver = com.mysql.jdbc.Driver
jdbcUrl = jdbc:mysql://localhost:3306/[Databasename]
jtaManaged = true
username = [Username]
password = [Password]
defaultAutoCommit = false
testOnReturn = true
testWhileIdle = true
timeBetweenEvictionRunsMillis = 60
initialSize = 2
minIdle = 2
validationQuery = "select 1"
</Resource>
Finger crossed that it will work without any further issue. If I don't update here anymore it will just have worked fine.
Further information:
Tomee DataSource Configuration
I implemented curator leader election example which is given in this site
Instead of having number of curator clients I added only one curator client as follows
public void selectLeader() {
CuratorFramework client = null;
try {
client = CuratorFrameworkFactory.newClient("localhost:2181", new ExponentialBackoffRetry(1000, 3));
LeaderSelectorService service = new LeaderSelectorService(client, "/leaderSelections", "LeaderElector");
client.start();
Thread.sleep(10000);
service.start();
} catch (Exception e) {
System.out.println("error"+e);
}finally
{
System.out.println("Shutting down...");
// CloseableUtils.closeQuietly(client);
}
}
public class LeaderSelectorService extends LeaderSelectorListenerAdapter implements Closeable {
private final String name;
private final LeaderSelector leaderSelector;
public LeaderSelectorService(CuratorFramework client, String path, String name) {
this.name = name;
// create a leader selector using the given path for management
// all participants in a given leader selection must use the same path
// ExampleClient here is also a LeaderSelectorListener but this isn't required
leaderSelector = new LeaderSelector(client, path, this);
// for most cases you will want your instance to requeue when it relinquishes leadership
leaderSelector.autoRequeue();
}
public void start() throws IOException
{
// the selection for this instance doesn't start until the leader selector is started
// leader selection is done in the background so this call to leaderSelector.start() returns immediately
leaderSelector.start();
}
#Override
public void takeLeadership(CuratorFramework arg0) throws Exception {
// we are now the leader. This method should not return until we want to relinquish leadership
final int waitSeconds = (int)(5 * Math.random()) + 1;
System.out.println(name + " is now the leader. Waiting " + waitSeconds + " seconds...");
//System.out.println(name + " has been leader " + leaderCount.getAndIncrement() + " time(s) before.");
try
{
Thread.sleep(TimeUnit.SECONDS.toMillis(waitSeconds));
}
catch ( InterruptedException e )
{
System.err.println(name + " was interrupted.");
Thread.currentThread().interrupt();
}
finally
{
System.out.println(name + " relinquishing leadership.\n");
}
}
#Override
public void close() throws IOException {
leaderSelector.close();
}
}
I have only one zookeeper instance and I am using Zookeeper 3.4.6, curator-framework 4.0.0 and curator-recipes 4.0.0.
when I start the client, it connects to zookeeper and in the log I can see "State change : connected" message.
Then I wait 10s and start leader election which gives me below error repeatedly.
2017-09-06 09:34:22.727 INFO 1228 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Unable to read additional data from server sessionid 0x15e555a719d0000, likely server has closed socket, closing socket connection and attempting reconnect
2017-09-06 09:34:22.830 INFO 1228 --- [c-1-EventThread] o.a.c.f.state.ConnectionStateManager : State change: SUSPENDED
2017-09-06 09:34:23.302 INFO 1228 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2017-09-06 09:34:23.303 INFO 1228 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Socket connection established, initiating session, client: /127.0.0.1:49594, server: localhost/127.0.0.1:2181
2017-09-06 09:34:23.305 INFO 1228 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x15e555a719d0000, negotiated timeout = 120000
2017-09-06 09:34:23.305 INFO 1228 --- [c-1-EventThread] o.a.c.f.state.ConnectionStateManager : State change: RECONNECTED
2017-09-06 09:34:23.310 WARN 1228 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Session 0x15e555a719d0000 for server localhost/127.0.0.1:2181, unexpected error, closing socket connection and attempting reconnect
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[na:1.8.0_131]
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[na:1.8.0_131]
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_131]
at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.8.0_131]
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[na:1.8.0_131]
at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:75) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:363) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1214) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
after some time it started to give me below error message.
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss
at org.apache.zookeeper.KeeperException.create(KeeperException.java:99) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
at org.apache.curator.framework.imps.CuratorFrameworkImpl.checkBackgroundRetry(CuratorFrameworkImpl.java:831) [curator-framework-4.0.0.jar:4.0.0]
at org.apache.curator.framework.imps.CuratorFrameworkImpl.processBackgroundOperation(CuratorFrameworkImpl.java:623) [curator-framework-4.0.0.jar:4.0.0]
at org.apache.curator.framework.imps.WatcherRemovalFacade.processBackgroundOperation(WatcherRemovalFacade.java:152) [curator-framework-4.0.0.jar:4.0.0]
at org.apache.curator.framework.imps.GetConfigBuilderImpl$2.processResult(GetConfigBuilderImpl.java:222) [curator-framework-4.0.0.jar:4.0.0]
at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:590) [zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:499) [zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
2017-09-06 09:34:31.897 INFO 1228 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2017-09-06 09:34:31.898 INFO 1228 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Socket connection established, initiating session, client: /127.0.0.1:49611, server: localhost/127.0.0.1:2181
2017-09-06 09:34:31.899 INFO 1228 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x15e555a719d0000, negotiated timeout = 120000
2017-09-06 09:34:31.899 INFO 1228 --- [c-1-EventThread] o.a.c.f.state.ConnectionStateManager : State change: RECONNECTED
2017-09-06 09:34:31.907 WARN 1228 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Session 0x15e555a719d0000 for server localhost/127.0.0.1:2181, unexpected error, closing socket connection and attempting reconnect
java.io.IOException: Xid out of order. Got Xid 41 with err -6 expected Xid 40 for a packet with details: clientPath:/leaderSelections serverPath:/leaderSelections finished:false header:: 40,12 replyHeader:: 0,0,-4 request:: '/leaderSelections,F response:: v{}
at org.apache.zookeeper.ClientCnxn$SendThread.readResponse(ClientCnxn.java:892) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:101) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:363) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1214) ~[zookeeper-3.5.3-beta.jar:3.5.3-beta-8ce24f9e675cbefffb8f21a47e06b42864475a60]
I tried several solution in the internet but non got succeeded. Does anybody know the root cause of this issue.
I have fixed this issue. There was version number mismatch between zookeeper version and curator version. I used curator version 4.0.0 with zookeeper 3.4.6. According to apache curator site
Curator 4.0.0 - compatible with ZooKeeper 3.5.x. I changed my curator version to 2.8.0
I wrote a program in Eclipse to test the remote connection to HBase. This is modified from HBase Example API Usage. It does very basic things: connect to hbase, drop a table if exists, then create a new one. Here's the code :
public class TableTest {
private static Configuration conf = null;
static{
conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum","192.168.12.120");
conf.set("hbase.zookeeper.property.clientPort","2181");
//conf.set("hbase.master", "192.168.12.120:12000"); // not work
}
public static void main(String[] args){
String tableName = "hbase_table";
try {
Connection connection = ConnectionFactory.createConnection(conf);
Admin admin = connection.getAdmin();
HTableDescriptor table = new HTableDescriptor(TableName.valueOf(tableName));
table.addFamily(new HColumnDescriptor("info"));
if(admin.tableExists(table.getTableName())){
admin.disableTable(table.getTableName());
admin.deleteTable(table.getTableName());
}
admin.createTable(table);
} catch (IOException e) {
e.printStackTrace();
}
}
}
However, I got some problems for making the connection work. The message is the following. On one side, the program searched the HRegionServer at 192.168.12.120 on port 16020, on another side, it searched the HMaster at localhost 127.0.0.1 on port 12000. This broke the connection, because both HRegionServer and HMaster are running at 192.168.12.120.
1294 DEBUG [2015-08-21 11:08:49] Use SIMPLE authentication for service ClientService, sasl=false
1311 DEBUG [2015-08-21 11:08:49] Connecting to /192.168.12.120:16020
1357 DEBUG [2015-08-21 11:08:49] Reading reply sessionid:0x14f39c8a9f20060, packet:: clientPath:null serverPath:null finished:false header:: 5,3 replyHeader:: 5,1210,0 request:: '/hbase,F response:: s{4,4,1439021727692,1439021727692,0,116,0,0,0,16,1191}
1360 DEBUG [2015-08-21 11:08:49] Reading reply sessionid:0x14f39c8a9f20060, packet:: clientPath:null serverPath:null finished:false header:: 6,4 replyHeader:: 6,1210,0 request:: '/hbase/master,F response:: #ffffffff000146d61737465723a3132303030ffffffc4ffffffbbffffffbcffffffd251ffffffb2ffffffe0ffffffb950425546a15a96c6f63616c686f737410ffffffe05d18ffffff89ffffffc5ffffffa1fffffff1fffffff42910018ffffff8a7d,s{1170,1170,1440125319355,1440125319355,0,0,0,94357651205521495,57,0,1170}
1369 DEBUG [2015-08-21 11:08:49] Use SIMPLE authentication for service MasterService, sasl=false
1369 DEBUG [2015-08-21 11:08:49] Connecting to localhost/127.0.0.1:12000
So how to set hbase master host at 192.168.12.120 ? Can somebody help ?
Here're 2 docs for the configuration :
Apache HBase ™ Reference Guide: 7. Default Configuration
Github: apache/hbase/.../hbase-default.xml
This is a followup to this question. I'm using the same configuration. However, I'm trying to use an internal website through a proxy server. I'm not sure if the following the correct way to configure a proxy in the simulation.
val httpConf = http.proxy("http://proxy.server.address", 8080)
Here is my modified code.
package foo
import io.gatling.core.Predef._
import io.gatling.core.session.Expression
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import io.gatling.http.Headers.Names._
import io.gatling.http.Headers.Values._
import scala.concurrent.duration._
import bootstrap._
import assertions._
class SimpleSimulation extends Simulation {
val httpConf = http.proxy("http://proxy.server.address", 8080)
val scn = scenario("My scenario")
.exec(http("My Page")
.get("http://10.128.3.232:9201/index.html"))
setUp(scn.inject(atOnce(50 user))).protocols(httpConf)
}
I've also modified conf/gatling.conf to include the proxy. I'm not sure what's the correct way to configure the proxy.
http {
#baseUrls = "" # default value for the base HTTP URLs
proxy {
host = "http://proxy.server.address" # proxy host (blank means no proxy)
port = 8080 # HTTP port
securedPort = -1 # HTTPS port (-1 means no HTTPS proxy)
#username = "" # proxy username (blank means no credentials)
#password = "" # proxy password
}
I'm getting the following exception when I run the simulation.
17:09:15.654 [INFO ] i.g.h.a.HttpRequestAction - Sending request 'My Page': scenario 'My scenario', userId #49
17:09:15.655 [WARN ] i.g.h.a.AsyncHandler - Request 'My Page' failed
java.nio.channels.UnresolvedAddressException: null
at sun.nio.ch.Net.checkAddress(Net.java:36) ~[na:1.6.0_51]
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:512) ~[na:1.6.0_51]
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:108) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:70) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:54) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.handler.codec.http.HttpClientCodec.handleDownstream(HttpClientCodec.java:97) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleDownstream(ChunkedWriteHandler.java:109) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.channel.Channels.connect(Channels.java:634) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.channel.AbstractChannel.connect(AbstractChannel.java:207) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:229) ~[netty-3.6.6.Final.jar:na]
at org.jboss.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:182) ~[netty-3.6.6.Final.jar:na]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1026) [async-http-client-1.7.19.20130706.jar:na]
Wrapped by: java.net.ConnectException: http://10.128.3.232:9201/index.html
at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:103) ~[async-http-client-1.7.19.20130706.jar:na]
at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) [netty-3.6.6.Final.jar:na]
at org.jboss.netty.channel.DefaultChannelFuture.addListener(DefaultChannelFuture.java:145) [netty-3.6.6.Final.jar:na]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.doConnect(NettyAsyncHttpProvider.java:1068) [async-http-client-1.7.19.20130706.jar:na]
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.execute(NettyAsyncHttpProvider.java:890) [async-http-client-1.7.19.20130706.jar:na]
at com.ning.http.client.AsyncHttpClient.executeRequest(AsyncHttpClient.java:520) [async-http-client-1.7.19.20130706.jar:na]
at io.gatling.http.ahc.HttpClient$.sendHttpRequest(HttpClient.scala:144) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction.io$gatling$http$action$HttpRequestAction$$sendRequest$1(HttpRequestAction.scala:75) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1$$anonfun$apply$2.apply(HttpRequestAction.scala:84) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1$$anonfun$apply$2.apply(HttpRequestAction.scala:81) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.core.validation.Success.map(Validation.scala:27) [gatling-core-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1.apply(HttpRequestAction.scala:81) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction$$anonfun$executeOrFail$1.apply(HttpRequestAction.scala:80) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.core.validation.Success.flatMap(Validation.scala:28) [gatling-core-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction.executeOrFail(HttpRequestAction.scala:80) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.core.action.Failable$class.execute(Actions.scala:82) [gatling-core-2.0.0-M3a.jar:na]
at io.gatling.http.action.HttpRequestAction.execute(HttpRequestAction.scala:54) [gatling-http-2.0.0-M3a.jar:na]
at io.gatling.core.action.Action$$anonfun$receive$1.applyOrElse(Actions.scala:42) [gatling-core-2.0.0-M3a.jar:na]
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:166) [scala-library-2.10.2.jar:na]
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:425) [akka-actor_2.10-2.1.4.jar:na]
at akka.actor.ActorCell.invoke(ActorCell.scala:386) [akka-actor_2.10-2.1.4.jar:na]
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:230) [akka-actor_2.10-2.1.4.jar:na]
at akka.dispatch.Mailbox.run(Mailbox.scala:212) [akka-actor_2.10-2.1.4.jar:na]
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:506) [akka-actor_2.10-2.1.4.jar:na]
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [scala-library-2.10.2.jar:na]
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [scala-library-2.10.2.jar:na]
17:09:15.656 [WARN ] i.g.h.a.AsyncHandlerActor - Request 'My Page' failed : http://10.128.3.232:9201/emontage/home.html
17:09:15.656 [DEBUG] i.g.h.a.AsyncHandlerActor -
>>>>>>>>>>>>>>>>>>>>>>>>>>
Request:
My Page: KO http://10.128.3.232:9201/index.html
=========================
Session:
Session(My scenario,49,Map(),1378847355391,0,List(),List(KO),List(),List())
=========================
HTTP request:
GET http://10.128.3.232:9201/index.html
=========================
HTTP response:
<<<<<<<<<<<<<<<<<<<<<<<<<
This has changed since 2013 when the question was originally answered. Their documentation link has changed, and the function definition for proxy has changed to be:
val httpConf = http.proxy(Proxy("myProxyHost", 8080))
As stated in the documentation, the first parameter is the host name, not the url.
Please use:
val httpConf = http.proxy("proxy.server.address", 8080)