Exception is thrown while opening SMB connection using smbj API. It says: "SMB 3.x support is not yet implemented". The exception is thrown from "SMB2NegotiateRequest.putCapabilities(SMBBuffer buffer)" method.
Below is the code snippet that opens the connection. The ides is to establish connection with server which supports any of the mentioned dialect version.
SMB2Dialect [] supportedSmdDialects = {
SMB2Dialect.SMB_2_0_2,
SMB2Dialect.SMB_2_1,
SMB2Dialect.SMB_2XX,
SMB2Dialect.SMB_3_0,
SMB2Dialect.SMB_3_0_2,
SMB2Dialect.SMB_3_1_1
};
SmbConfig cfg = SmbConfig.builder().
withDialects(supportedSmdDialects).
withMultiProtocolNegotiate(true).
build();
SMBClient client = new SMBClient(cfg);
Connection conn = client.connect(host); // This line throws
In anything wrong with this code, or smb v3x is not implemented in fact?
Currently indeed SMBv3 support is not implemented. To connect, remove the SMB3+ dialects from the array.
Related
I've been following the tutorial here to configure a proxy service with WCF for synchronization. But all the examples I see the ClientProvider is for SqlServer Compact Edition. Can it be done with the SqlSyncProvider for SQL Server Express?
For example my code is:
var svc = new ServiceForSyncClient();
ServerSyncProvider serverProvider = new ServerSyncProviderProxy(svc);
// create the sync orhcestrator
var syncOrchestrator = new SyncOrchestrator
{
LocalProvider = new SqlSyncProvider("ProductsScope", clientConn),
RemoteProvider = serverProvider,
Direction = SyncDirectionOrder.DownloadAndUpload
};
var syncStats = syncOrchestrator.Synchronize();
But when synchronizing, I get an exception:
An unhandled exception of type 'System.InvalidCastException' occurred
in Microsoft.Synchronization.dll
Additional information:
Microsoft.Synchronization.KnowledgeSyncProvider
you're using two completely different sync providers. part of your code is using the the older offline providers (DBServerSyncProvider and SQLCEClientSyncProvider) and you're trying to use the SQLSyncProvider which is part of the newer knowledge-based/peer-to-peer sync provider (SqlSycProvider/SqlCeSyncProvider).
You can't mix and match the older and newer sync providers
If you want to use SQL Express as the client, here is a sample for using it with WCF
We are using OpenDJ SDK for connecting with Directory Services. Below mentioned is code.
#Bean
public LDAPConnectionFactory createConnectionFactory(){
LDAPOptions ldapOptions = new LDAPOptions();
ldapOptions.setTimeout(30, TimeUnit.SECONDS);
final LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port,ldapOptions);
Connections.newFixedConnectionPool(factory,connectionPoolSize);
return factory;
}
connection pool size parameter is set to 10 at present. The code was working fine, suddenly it started returning null object for getConnection() method on factory. When I comment out Connections.newFixedConnectionPool statement it works as per expected. Are we missing anything.
If you are creating a fixed connection pool, you should request a connection from it, not from the factory.
The issue is that you are actually not saving the returned pool.
When trying to run the following in Redis using booksleeve.
using (var conn = new RedisConnection(server, port, -1, password))
{
var result = conn.Server.FlushDb(0);
result.Wait();
}
I get an error saying:
This command is not available unless the connection is created with
admin-commands enabled"
I am not sure how do i execute commands as admin? Do I need to create an a/c in db with admin access and login with that?
Updated answer for StackExchange.Redis:
var conn = ConnectionMultiplexer.Connect("localhost,allowAdmin=true");
Note also that the object created here should be created once per application and shared as a global singleton, per Marc:
Because the ConnectionMultiplexer does a lot, it is designed to be
shared and reused between callers. You should not create a
ConnectionMultiplexer per operation. It is fully thread-safe and ready
for this usage.
Basically, the dangerous commands that you don't need in routine operations, but which can cause lots of problems if used inappropriately (i.e. the equivalent of drop database in tsql, since your example is FlushDb) are protected by a "yes, I meant to do that..." flag:
using (var conn = new RedisConnection(server, port, -1, password,
allowAdmin: true)) <==== here
I will improve the error message to make this very clear and explicit.
You can also set this in C# when you're creating your multiplexer - set AllowAdmin = true
private ConnectionMultiplexer GetConnectionMultiplexer()
{
var options = ConfigurationOptions.Parse("localhost:6379");
options.ConnectRetry = 5;
options.AllowAdmin = true;
return ConnectionMultiplexer.Connect(options);
}
For those who like me faced the error:
StackExchange.Redis.RedisCommandException: This operation is not
available unless admin mode is enabled: ROLE
after upgrading StackExchange.Redis to version 2.2.4 with Sentinel connection: it's a known bug, the workaround was either to downgrade the client back or to add allowAdmin=true to the connection string and wait for the fix.
Starting from 2.2.50 public release the issue is fixed.
I'm using SQL Azure in a Windows Azure app running as a cloud service. Most of the time my database actions works completely fine (that is, after handling all sorts of timeouts and what not), however i'm running into a problem that seems
using (var connection = new SqlConnection(m_connectionString))
{
m_ConnectionRetryPolicy.ExecuteAction(() => connection.Open());
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT * FROM X WHERE Y = Z";
var reader = m_CommandRetryPolicy.ExecuteAction(() => command.ExecuteReader());
return LoadData(reader).FirstOrDefault();
}
}
The line that fails is the Command.ExecuteReader with an:
ExecuteReader requires an open and available Connection. The connection's current state is closed
Things that i have already considered
I'm not "reusing" an old connection or saving a connection is a member variable
There should be no concurrency issues - the repository class that these methods belong to is created each time it is needed
Have anyone else experienced this? I could of course just add this to the list of exception which would yield a retry, but I'm not very comfortable with that as
I had a bunch of these errors a few days ago (West Europe) on my production deployment, but they went away by themselves. At the same time I was seeing timeouts, throttling and other errors from SQL Azure. I assume that there was a temporary problem with the platform (or at least the server that I am running on).
You probably aren't doing anything wrong in your code, but are suffering from degraded performance on SQL Azure. Try and handle the errors, perform retries, exponential back-off, queues (to reduce concurrency), splitting your load across databases — that sort of thing.
write every thing within try and catch,finally block.
as follows:
try
{
con.open();
m_ConnectionRetryPolicy.ExecuteAction(() => connection.Open());
using (var command = connection.CreateCommand())
{
command.CommandText = "SELECT * FROM X WHERE Y = Z";
var reader = m_CommandRetryPolicy.ExecuteAction(() => command.ExecuteReader());
return LoadData(reader).FirstOrDefault();
}
con.close();
}
catch(exception ex)
{
}
finally
{
con.close();
}
Remember to close connection in finally block as well.
There is an Enterprise Library that MS has produced specifically for SQL Azure, here are some examples from their patterns and Practice.
It's similar to what you are doing, however it does more on the reliability (and these examples show how to get a reliable connection)
http://msdn.microsoft.com/en-us/library/hh680899(v=pandp.50).aspx
Are you sure it's the reader that's failing and not the opening of the connection? I'm encountering an exception when I wrap the connection.Open() in the m_ConnectionRetryPolicy.ExecuteAction().
However it works just fine for me if I skip the ExecuteAction wrapper and open the connection using connection.OpenWithRetry(m_ConnectionRetryPolicy).
And I'm also using command.ExecuteReaderWithRetry(m_ConnectionRetryPolicy) which is working for me.
I have no idea though why it's not working when wrapped in ExecuteAction though.
I believe this means that Azure has closed the connection behind the scenes, without telling the connection pooler. This is by design. So, the connection pooler gives you what it thinks is an available, open connection, but when you try to use it, it finds out it's not open after all.
This seems very clunky to me, but it's the way Azure is at the moment.
function openDatabase():void
{
var dbFile:File = File.applicationStorageDirectory.resolvePath("database.db");
connection = new SQLConnection();
connection.addEventListener(SQLEvent.OPEN, onOpen);
connection.openAsync(dbFile, "create");
}
i used this code in AIR to create connection and it's working but where is the database file??
where is the applicationStorageDirectory??
It's platform dependent (Mac, Windows, etc.). If you print out the value of "File.applicationStorageDirectory.nativePath", it will give you the fully-specified path on the filesystem of your current platform.