# Enqueing Hangfire Job getting SqlException (0x80131904): Array cannot be null.

**URL:** <https://discuss.hangfire.io/t/enqueing-hangfire-job-getting-sqlexception-0x80131904-array-cannot-be-null/8926>\
**Category:** bug?\
**Tags:** sql-server, aspnetcore\
**Created:** [January 27, 2022, 6:18pm UTC](https://discuss.hangfire.io/t/enqueing-hangfire-job-getting-sqlexception-0x80131904-array-cannot-be-null/8926 "2022-01-27T18:18:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexei](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@Alexei](https://discuss.hangfire.io/u/Alexei)\
**Post date:** [January 27, 2022, 6:18pm UTC](https://discuss.hangfire.io/t/enqueing-hangfire-job-getting-sqlexception-0x80131904-array-cannot-be-null/8926/1 "2022-01-27T18:18:41Z")

</div>

Environment:  
.Net 5.0  
Docker  
SQL Server 2019  
Hangfire: 1.17.28

Works with non-dockersized execution. But having issues with Docker.

Successfully connecting to SQL Server with .UseSqlServerStorage(connectionString, options) but  
Enqueing Job from Docker Container getting the below error.

Hangfire.BackgroundJobClientException: Background job creation failed. See inner exception for details.\n —\>  
System.Data.SqlClient.SqlException (0x80131904): Array cannot be null. (Parameter ‘bytes’)\n  
at System.Text.Encoding.GetString(Byte[] bytes)\n  
at System.Text.UTF8Encoding.UTF8EncodingSealed.GetString(Byte[] bytes)\n  
at System.Data.SqlClient.SNI.SNIProxy.GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, Byte[] receivedBuff, Byte[]& sendBuff, Byte[] serverName)\n  
at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.GenerateSspiClientContext(Byte[] receivedBuff, UInt32 receivedLength, Byte[]& sendBuff, UInt32& sendLength, Byte[] \_sniSpnBuffer)\n  
at System.Data.SqlClient.TdsParser.SNISSPIData(Byte[] receivedBuff, UInt32 receivedLength, Byte[]& sendBuff, UInt32& sendLength)\n  
at System.Data.SqlClient.SqlInternalConnectionTds…ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionS  
tring userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)\n  
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)\n  
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)\n  
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\n  
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)\n  
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCr  
eate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)\n  
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)\n at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)\n  
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\n at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\n  
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)\n at System.Data.SqlClient.SqlConnection.Open()\n at Hangfire.SqlServer.SqlServerStorage.CreateAndOpenConnection()\n at Hangfire.SqlServer.SqlServerStorage.UseConnection[T](DbConnection dedicatedConnection, Func`2 func)\n  
at Hangfire.SqlServer.SqlServerConnection.CreateExpiredJob(Job job, IDictionary`2 parameters, DateTime createdAt, TimeSpan expireIn)\n at Hangfire.Client.CoreBackgroundJobFactory.<>c __DisplayClass14_0.<Create>b__ 2(Int32 _)\n at Hangfire.Client.CoreBackgroundJobFactory.RetryOnException[T](Int32& attemptsLeft, Func`2 action)  
\n— End of stack trace from previous location —\n  
at Hangfire.Client.CoreBackgroundJobFactory.RetryOnException[T](Int32& attemptsLeft, Func`2 action)\n at Hangfire.Client.CoreBackgroundJobFactory.Create(CreateContext context)\n at Hangfire.Client.BackgroundJobFactory.<>c __DisplayClass12_0.<CreateWithFilters>b__ 0()\n at Hangfire.Client.BackgroundJobFactory.InvokeClientFilter(IClientFilter filter, CreatingContext preContext, Func`1 continuation)\n at Hang  
fire.Client.BackgroundJobFactory.\<\>c\_\_DisplayClass12\_1.b\_\_2()\n  
at Hangfire.Client.BackgroundJobFactory.CreateWithFilters(CreateContext context, IEnumerable`1 filters)\n at Hangfire.Client.BackgroundJobFactory.Create(CreateContext context)\n at Hangfire.BackgroundJobClient.Create(Job job, IState state)\nClientConnectionId:dd8edb40-1471-4a41-a66c-a2f748aec499\n --- End of inner exception stack trace ---\n at Hangfire.BackgroundJobClient.Create(Job job, IState state)\n at Hangfire.BackgroundJobClientExtensions.Create(IBackgroundJobClient client, Expression`1 methodCall, IState state)\n  
at Hangfire.BackgroundJobClientExtensions.Schedule(IBackgroundJobClient client, Expression`1 methodCall, TimeSpan delay)\n at Hangfire.BackgroundJob.Schedule(Expression`1 methodCall, TimeSpan delay)\n  
at Hangfire.Server.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, IBackgroundJobClient backgroundJobClient, IRecurringJobManager recurringJobManager, IServiceProvider serviceProvider)

---

<div class="post-metadata">

**Author:** ![Alexei](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@Alexei](https://discuss.hangfire.io/u/Alexei)\
**Post date:** [February 3, 2022, 8:07pm UTC](https://discuss.hangfire.io/t/enqueing-hangfire-job-getting-sqlexception-0x80131904-array-cannot-be-null/8926/2 "2022-02-03T20:07:38Z")

</div>

Resolved by using the connection string format: “Server=tcp,port;Database=myDbName;User Id=myUsername;Password=myPassword;”  
where tcp and port are found sql server tcpid properties.

---

<div class="post-metadata">

**Author:** ![odinserj](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/odinserj/32/648_2.png) [@odinserj](https://discuss.hangfire.io/u/odinserj)\
**Post date:** [February 4, 2022, 7:14am UTC](https://discuss.hangfire.io/t/enqueing-hangfire-job-getting-sqlexception-0x80131904-array-cannot-be-null/8926/3 "2022-02-04T07:14:58Z")

</div>

Looks like a bug in the System.Data.SqlClient great packet. Please try to reference the `System.Data.SqlClient` NuGet package of the latest version to your project explicitly.
