How do I recreate NoRouteToHostException scenario? - exception

Existing Java code (client side of TCP client-server) recently encountered a NoRouteToHostException for the first time. It did not handle the exception correctly. I've adjusted the code to handle that exception. How can I create a NoRouteToHostException scenario in a lab environment so I can test that my fix handles the exception correctly?

throw new NoRouteToHostException

Related

Unable to cast COM object of type 'System.__ComObject' to interface type

I am really pulling my hair out at this one. I have literally no idea why I am having these issues.
Right, I have 3 SSIS packages. One for development, one for user acceptance testing and one for a live release. Each package is pretty much an exact copy of the development one, just using different connection strings.
The development and UAT package work perfectly fine, no issues. And have been working for the 6 months since they've been created. I came to creating the LIVE package two days ago. I made a copy of the UAT package and changed connection strings. All was well. I then closed the package and it began validating the connections. It began taking a long time to validate the connections compared to the other two, in fact. It seems to repeatedly validate the same connections over and over again. Eventually, after about 10 minutes it stops and gives me this error message:
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSObject100'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{D4E5AF42-7999-473C-8082-6EFC676953C4}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).
I looked this up online, I have followed the instructions on registering my DLLs. No changes at all. I uninstalled the MariaDB (MySQL) instance from ther server. Reinstalled it, amended all the settings and gave it another crack. This time I posted a previous question on how to fix the problem. Someone told me that I cannot create a copy from the other packages unless I change the GUID. I didn't believe this to be true as I had done so before. Anyway, I copied the package and changed the GUID. This again, did not work. So instead I created a whole new package and created the control flow again and again. This did not work.
I am at a loose end and have no idea why this just will not work. Our application is slated for release in less than 2 weeks and this issue just will not leave. Can anyone help?
EDIT: THE QUESTION YESTERDAY DID NOT RECEIVE A CORRECT ANSWER. Please do not close this question.

Meteor throws throwIfSelectorIsNotId exception

When running some code Meteor throws a throwIfSelectorIsNotId exception. I have two clients running the same code and the exception is thrown when the second client is running the same pice of code.
Cant figure out what this exception means and why it is thrown. Hopefully someone will be able to explain it.
For certain operations on the client (since version 0.57 I think it was). When doing an update operation e.g
MyCollection.update({name:"John Doe"},{$set:{age:50}});
You need to split it into two parts, on the client. (Only on the client).
var doc_id = MyCollection.findOne({name:"John Doe"})._id;
MyCollection.update({_id:doc_id,{$set:{age:50}});
You need to find the document by the _id first then update that document. The selector can only be an _id for update & remove operations.
This is because of a security risk with meteor's design, if there were to be a client side mongodb database it could arbitrarily get information from the server on other operations while determining on whether to allow the update or not. It was introduced in Meteor 0.57.

PetaPoco Should I use MultipleActiveResultSets=True?

From time to time we receive the following database connection error from PetaPoco in an ASP.NET MVC 4 app:
There is already an open DataReader associated with this Command which must be closed first.;
System.Data; at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)...
It seems like this happens as we get more load to the system.
Some suggestions we found as we researched were:
Do a PetaPoco Fetch instead of a Query
Add MultipleActiveResultSets=True to our connection string
Can someone with PetaPoco experience verify that these suggestions would help?
Any other suggestions to avoid the Exception would be appreciated.
Update 06/10/2013 We changed the Query to a Fetch and we have seen some improvement however we still sometimes see the error.
Does anyone know what drawbacks changing the connection string to MultipleActiveResultSets=True might have?
Be sure that you are creating the PetaPoco DB per request (not a static).
See: how to create a DAL using petapoco
Update 06/10/2013 All Fetch methods calls the Query method (see the source)
So changing one for the other has no effect on the error.
The drawbacks are listed on the MSDN and includes warnings with:
Statement Interleaving
Session Cache
Thread Safety
Connection Pooling
Parallel Execution
I have tried it personally and didn't got any drawbacks (depends on your app), but didn't get rid of the errors also.
The only thing that you can do to remove the error, it's follow your request code to find where in the code the statement is called twice, and then use other DB connection in that function.
Also, you can catch the error and then create a new db connection and try with that new one.
Sorry but not magic bullet here.

DataContext Not Seeing Updates

I am using Unity 2.0 to register a concrete SQL Server repository against an abstract repository like so:
var context = new DataContext(
ConfigurationManager.ConnectionStrings["DevDB"].ConnectionString
);
this.UnityContainer
.RegisterType<AlertQueueRepository, Sql.AlertQueueRepository>(
new InjectionConstructor(context)
);
The context is being shared across all of the other repositories that I have. This works fine within the application, however, if someone else - SSMS query, SSIS package, other application - modifies the database my repositories are unaware of this and will not see the change.
Is this an issue with the way I'm using Unity? Perhaps the contexts are hanging around too long? Or is it something I need to configure with LINQ?
Consider the answer to this question: Multiple application using one database?.
If you really need multiple applications to access/modify the data, consider building a layer on top of the database to service all the requests.
This question was similar to mine it turns out - ASP.NET MVC inject per request.
What I needed to do was have each request register its own context as it has the side-effect that the context gets thrown out after each request. Now I'm just left to consider the performance implications of this pattern.

LINQ to SQL Delayed Evaluation Exception Handling

I have a LINQ to SQL/Unity/ASP.NET MVC/SQL Server application hosted on Azure. I am using Lazy Evaluation throughout the whole site. The Application is using a TCP connection to SQL Server and every so often I get a "A transport-level error has occurred when sending the request to the server." SqlException.
Well since the the query is getting materialized when it is called later in code, I can't just wrap a specific piece of code with a try/catch.
Is there a way that I can handle this exception by implementing an interface or attaching a delegate to the DataContext?
If you use the results from linq as-is, then you have to handle the error in the code that materializes the data. However, instead of simply returning the linq query results directly, you could wrap it in an IEnumerable implementation of your own design, which is free to implement whatever error handling you like. This way the code that consumes the IEnumerable doesn't have to handle the exception.
I think that the only way to fix this is to wrap the code that is triggering (materializing) the call to the SQL server in a try catch.