Reputation: 965
I wrote a console application in C# that uses ODP.NET to listen to database change notifications from an Oracle database. The console application works perfectly. I wrote a Windows service with the same code, but in the Windows service OracleDependency.OnChange
is never firing.
Here is the code I am using to register for a database change notification:
string sql = GenerateQuery();
using (OracleConnection conn = new OracleConnection(connectionString))
using (OracleCommand cmd = new OracleCommand(sql, conn))
{
conn.Open();
// Register a listener for the database change notification event
OracleDependency dep = new OracleDependency(cmd);
dep.OnChange += (sender, args) =>
{
// Do stuff..
};
cmd.ExecuteNonQuery();
}
I can see the notification in the database by querying the user_change_notification_regs
table, but the client never receives the callback. Again, in the console application version (with the same code), the client receives the callback perfectly.
The Windows service is running as a Network Service. I have also tried Local System, and neither appear to be working. Any ideas?
Thanks!
Upvotes: 2
Views: 1739
Reputation: 965
The service needed an exception in Windows Firewall. It worked flawlessly after adding the exception.
Upvotes: 1