Failed to connect to an IPC Port: The system cannot find the file specified - .net-remoting

In my .net 2.0 application Remote object suddenly destroyed and thrown the below exception.
"Failed to connect to an IPC Port: The system cannot find the file specified."
I have IPC remoting server and which create a singleton object.
i have override the InitializeLifetimeService() method and returns null for infinite lifetime.
server and client applications are working fine but some times we got the above exception.
serverCode:
//create and register the processheartbeat.
BinaryServerFormatterSinkProvider serverprovider = new BinaryServerFormatterSinkProvider();
serverprovider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
//Hosts the Heartbeat object and registers it.
processHeartbeatChn = new IpcServerChannel("HeartbeatChannel", "localhost:" + applicationHeartbeatPort, serverprovider);
//registers the channel
ChannelServices.RegisterChannel(processHeartbeatChn, false);
//register the service
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Heartbeat),
appName, WellKnownObjectMode.Singleton);
ClientCode:
string uri = string.Format(CultureInfo.InvariantCulture,"ipc://localhost:{0}/{1}", applicationHeartbeatPort, appName);
//get the Heartbeat object
remoteHeartbeat = (Heartbeat)Activator.GetObject(typeof(Heartbeat), uri);
any hot fix is there to resolve this problem?
can any one help me an this?

Related

Embedded node-red in a feathersjs application get websocket error

I can embed node-red with a custom service with the following node-red.service.js :
// Initializes the `node-red` service on path `/red`
const { NodeRed } = require('./node-red.class');
const hooks = require('./node-red.hooks');
const RED = require("node-red");
module.exports = function (app) {
const paginate = app.get('paginate');
const options = {
paginate
};
// Create the node-red settings object
const settings = {
httpAdminRoot:"/red",
httpNodeRoot: "/red",
userDir: "./red",
functionGlobalContext: { } // enables global context
};
// Initialise the runtime with a server and settings
RED.init(app,settings);
// Serve the editor UI from /red
app.use('/red' , RED.httpAdmin );
RED.start()
};
If I go to localhost:3030/red I get the node-red page, but after few seconds it lost connection to server with the following error:
WebSocket connection to 'ws://localhost:3030/red/comms' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I think there is a problem serving thru websocket or maybe since /red/comms is not defined in feathersjs it can't connect. Any idea?
Thank you
The issue comes with this line:
// Initialise the runtime with a server and settings
RED.init(app,settings);
As the comment says, you need to initialise the runtime with a server object. Here you are passing it an Express application, not a server.
It is not possible to mount websocket listeners on an express app - Node-RED needs access to the underlying HTTP Server object.
I am not familiar with what apis featherjs provides, but it does appear to allow you access to the http server object - for example by calling app.listen yourself - https://docs.feathersjs.com/api/express.html#app-listen-port

UWP VPN - VpnPlugin connect implementation throws exception in StartWithMainTransport

Kindly see the UWP code snippet below tried on Windows 10 desktop using Visual Studio 2017 community edition.
The code implements Custom IVpnPlugin module. When system's VPN configuration is selected to this app and connect is done, the application's task gets triggered and VPN plugin's "Connect()" method gets invoked.
However, following code steps face exception while executing StartWithMainTransport(…).
("The operation was cancelled by user") on Visual Studio.
On the system's VPN settings following error is seen - "remote access service ip configuration is unusable"
I think I am passing correctly v4 and v6 address to the channel->StartWithMainTransport(…) API which are bound to my m/c network I/f. What other validations may have caused this issue. I do not want to configure certificates etc for the VpnChannel as I plan to implement encapsulate and decapsulate myself in VpnPlugin.
// Sample Plugin's connect implementation
void TunnelPlugin::Connect(Windows::Networking::Vpn::VpnChannel^ channel)
{
this->dSock = ref new DatagramSocket();
channel->AssociateTransport(this->dSock, nullptr); // No difference even if this statement is moved after ConnectAsync().
Platform::String^ svcName = "22111";
auto result = create_task(dSock->BindServiceNameAsync(svcName));
result.get();
// Connect to the destination tunnel address on UDP socket.
HostName^ remoteTunnelIP = ref new HostName("192.168.1.137");
Platform::String^ remoteTunnelPort = "22112";
result = create_task(this->dSock->ConnectAsync(remoteTunnelIP, remoteTunnelPort));
result.get();
VpnChannelConfiguration^ chanCfg = channel->Configuration;
// IP destinations to be routed via VPN
VpnRouteAssignment^ routeScope = ref new VpnRouteAssignment();
routeScope->Ipv4InclusionRoutes->Append(ref new VpnRoute(ref new HostName("192.168.1.111"), 32));
Vector<HostName^>^ localV4Addrs = ref new Vector<HostName^>;
localV4Addrs->Append(ref new HostName("192.168.1.133")); // Local host name to be bound.
Vector<HostName^>^ localV6Addrs = ref new Vector<HostName^>;
localV6Addrs->Append(ref new HostName("fc00::44fd:d3ed:b02a:a05e"));
Vector<HostName^>^ dnsServers = ref new Vector<HostName^>;
dnsServers->Append(ref new HostName("1.1.1.1"));
VpnDomainNameInfo^ dnsInfo = ref new VpnDomainNameInfo(".", VpnDomainNameType::Suffix, dnsServers, ref new Vector<HostName^>);
VpnDomainNameAssignment^ dnsAssignment = ref new VpnDomainNameAssignment;
dnsAssignment->DomainNameList->Append(dnsInfo);
try
{
// Throws exception here.
channel->StartWithMainTransport(localV4Addrs->GetView(), localV6Addrs->GetView(), nullptr, routeScope, dnsAssignment, 1400, 1412, false, this->dSock);
}
catch (Exception^ exc)
{
auto type = exc->GetType();
Platform::String^ str = exc->ToString();
}
}

Connection time out in jpos client

I am using jpos client (In one of the class of java Spring MVC Program) to connect the ISO8585 based server, however due to some reason server is not able to respond back, due to which my program keeps waiting for the response and results in hanging my program. So what is the proper way to implement connection timeout?
My client program look like this:
public FieldsModal sendFundTransfer(FieldsModal field){
try {
JposLogger logger = new JposLogger(ISO_LOG_LOCATION);
org.jpos.iso.ISOPackager customPackager = new GenericPackager(ISO_PACKAGER);
ISOChannel channel = new PostChannel(ISO_SERVER_IP, Integer.parseInt(ISO_SERVER_PORT), customPackager);// live
logger.jposlogconfig(channel);
channel.connect();
log4j.info("Connection established using PostChannel");
ISOMsg m = new ISOMsg();
m.set(0, field.getMti());
//m.set(2, field.getField2());
m.set(3, field.getField3());
m.set(4, field.getField4());
m.set(11, field.getField11());
m.set(12, field.getField12());
m.set(17, field.getField17());
m.set(24, field.getField24());
m.set(32, field.getField32());
m.set(34, field.getField34());
m.set(41, field.getField41());
m.set(43, field.getField43());
m.set(46, field.getField46());
m.set(49, field.getField49());
m.set(102,field.getField102());
m.set(103,field.getField103());
m.set(123, field.getField123());
m.set(125, field.getField125());
m.set(126, field.getField126());
m.set(127, field.getField127());
m.setPackager(customPackager);
System.out.println(ISOUtil.hexdump(m.pack()));
channel.send(m);
log4j.info("Message has been send");
ISOMsg r = channel.receive();
r.setPackager(customPackager);
System.out.println(ISOUtil.hexdump(r.pack()));
channel.disconnect();
}catch (Exception err) {
System.out.println("sendFundTransfer : " + err);
}
return field;
}
Well the real proper way would be to use Q2. Given you don't need a persistent connection you coud just set a timeout for the channel.
PostChannel channel = new PostChannel(ISO_SERVER_IP, Integer.parseInt(ISO_SERVER_PORT), customPackager);// live
channel.setTimeout(timeout); //timeout in millies.
This way channel will autodisconnect if nothing happens during the time specified by timeout , and your call to receive will throw an exception.
The alternative is using Q2 and a mux (see QMUX, for which you need to run Q2, or ISOMUX which is kind of deprecated).

IBM Watson Conversation Service Using Proxy settings from Java API

I have developed a conversation service using IBM Watson and deployed. I am able to access my service using the IBM Watson API explorer. I tried connecting the service using a Java API as explained in https://developer.ibm.com/recipes/tutorials/integration-of-ibm-watson-conversation-service-to-your-java-application/ I am working on a corporate network, so using proxy to access internet. Now I am not able to access the service from my Java API. I am getting below error.
Exception in thread "main" java.lang.RuntimeException: java.net.ConnectException: Failed to connect to gateway.watsonplatform.net/169.48.66.222:443
at com.ibm.watson.developer_cloud.service.WatsonService$1.execute(WatsonService.java:182)
at com.chat.CustomerChat.conversationAPI(CustomerChat.java:47)
at com.chat.CustomerChat.main(CustomerChat.java:32)
Caused by: java.net.ConnectException: Failed to connect to gateway.watsonplatform.net/169.48.66.222:443
at okhttp3.internal.io.RealConnection.connectSocket(RealConnection.java:187)
at okhttp3.internal.io.RealConnection.buildConnection(RealConnection.java:170)
at okhttp3.internal.io.RealConnection.connect(RealConnection.java:111)
at okhttp3.internal.http.StreamAllocation.findConnection(StreamAllocation.java:187)
at okhttp3.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:123)
at okhttp3.internal.http.StreamAllocation.newStream(StreamAllocation.java:93)
at okhttp3.internal.http.HttpEngine.connect(HttpEngine.java:296)
at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:248)
at okhttp3.RealCall.getResponse(RealCall.java:243)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
at okhttp3.RealCall.execute(RealCall.java:57)
How do we set proxy connection in IBM watson Connection service?
My code:(Modified the user credentials and workspace id here)
ConversationService service = new ConversationService("2017-05-26");
service.setUsernameAndPassword("dfgdfg-578a-46b6-55hgg-ghgg4343", "ssdsd455gfg");
MessageRequest newMessage = new MessageRequest.Builder().inputText(input).context(context).build();
String workspaceId = "fgfdgfgg-ce7a-422b-af23-gfgf56565";
MessageResponse response = service.message(workspaceId, newMessage).execute();
Not completely sure about work around for Java, but when i had similar issue with Node, i had to set up proxy variables and that helped. I would recommend you to give a try by setting up proxy variables in eclipse and JVM. And also i think this Java file must be helpful.
After going though IBM API documentation I found below method to set the proxy. It should work.
HttpConfigOptions config = new HttpConfigOptions
.Builder()
.proxy(new Proxy(Proxy.Type.HTTP,
new InetSocketAddress("<Proxy IP>", <Proxy Port>)))
.build();
service.configureClient(config);
I implemented this code with Java-sdk 6.14.0. IBM has discontinued ConversationService package and deprecated Conversation package in this version of SDK. Instead Assistant package has been introduced. My working code is as below.
Assistant service = null;
Context context = null;
if (watsonUser.equalsIgnoreCase(APIKEY_AS_USERNAME))
{
IamOptions iamOptions = new IamOptions.Builder().apiKey(watsonApikey).build();
service = new Assistant(watsonVersion, iamOptions);
}
else
{
service = new Assistant(watsonVersion, watsonUser,watsonPassword);
}
service.setEndPoint(watsonUrl);
if(watsonProxy != null)
{
HttpConfigOptions config = new HttpConfigOptions
.Builder()
.proxy(new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(watsonProxyIP, watsonProxyPort)))
.build();
service.configureClient(config);
}
String workspaceId = watsonWorkspace_id;
InputData input = new InputData.Builder(inputStr).build();
MessageOptions options = new MessageOptions.Builder(workspaceId)
.context(context)
.input(input)
.build();
MessageResponse response = service.message(options).execute();
context = response.getContext();
I have checked the code with Conversation package based implementation. It worked. I couldn't checked with code given in the question as ConversationService package is no more in the current SDK.

MQQueueManager: What to expect from isConnected state after creation, during use?

I inherited this lovely bit of code below.
The way I read it the developer makes three assumptions:
An MQQueueManager instance is not necessarily created in a state where isConnected() returns true
If it is created in state isConnected() == false, the state might change "later", hence the timeout code
If you try to create an access queue from a disconnected MQQueueManager, it will not throw an exception.
What I would expect is that an MQQueueManager instance is created in state isConnected() == true, that this state might change later (network failure etc), and that this state change (isConnected() == false) would cause an operation on the queue to fail with an MQException.
The documentation is delightfully silent on these points, except to note that the only way to reconnect to a queue after manually disconnecting the MQQueueManager is to create a new instance of MQQueueManager.
Who can set me straight here?
qMgr = new MQQueueManager( qManager );
// Set up the options on the queue we wish to open...
// Note. All WebSphere MQ Options are prefixed with MQC in Java.
final int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
// Now specify the queue that we wish to open,
// and the open options...
queue = qMgr.accessQueue( queueName, openOptions );
// Set the get message options...
final MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the
// defaults
gmo.options = MQC.MQGMO_WAIT;
gmo.waitInterval = 1000;
connectionStatus = CONNECTING;
int timeOutCounter = 0;
while(!qMgr.isConnected()) {
InboundMsgTask.sleep(1000);
timeOutCounter++;
if(timeOutCounter > 4) {
connectionStatus = TIME_OUT;
return;
}
}
connectionStatus = CONNECTED;
Instead of checking the IsConnected==True, it is better to go ahead make the actual MQ .NET method call (Get, Put etc). If the connection is broken these calls would throw a connection broken execption (MQRC 2009). Remember the IsConnected could be True before a MQ method is called but it can change during the execution of a MQ method. Your code needs to handle the connection broken exception and call the MQQueueManager.Disconnect method and then re-establish the connection. The Disconnect call would free up any resources allocated and close all gracefully any queue manager objects that were opened. Ignore any exception thrown by the Disconnect method.
If you are using MQ v7.1 or v7.5, then the .NET client can automatically reconnect to queue manager if it detects connection errors. You will need to enable the automatic reconnect option. Please see the MQ InfoCenter.
EDIT:
A new MQQueueManager() will return an instance of MQQueueManager class if connection to queue manager is successfully established. In case of errors, a MQExceptionwill be thrown. There is no need to wait for connection to complete as MQQueueManager constructor is a blocking call.

Resources