I am struggling to troubleshoot a System.Format exception that results from parsing my Akka.Net config file.
I know that the exception stems from the persistence block of the configuration:
persistence{
journal {
plugin = "akka.persistence.journal.sql-server"
sql-server {
# qualified type name of the SQL Server persistence journal actor
class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"
# dispatcher used to drive journal actor
plugin-dispatcher = "akka.actor.default-dispatcher"
# connection string used for database access
connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
# default SQL commands timeout
connection-timeout = 30s
# SQL server schema name to table corresponding with persistent journal
schema-name = dbo
# SQL server table corresponding with persistent journal
table-name = EventJournal
# should corresponding journal table be initialized automatically
auto-initialize = off
# timestamp provider used for generation of journal entries timestamps
timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"
# metadata table
metadata-table-name = Metadata
}
}
snapshot-store {
sql-server {
# qualified type name of the SQL Server persistence journal actor
class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"
# dispatcher used to drive journal actor
plugin-dispatcher = ""akka.actor.default-dispatcher""
# connection string used for database access
connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
# default SQL commands timeout
connection-timeout = 30s
# SQL server schema name to table corresponding with persistent journal
schema-name = dbo
# SQL server table corresponding with persistent journal
table-name = SnapshotStore
# should corresponding journal table be initialized automatically
auto-initialize = off
}
}
}
The output reflecting the exception is the following:
Binding session to 'C:\Users\Snimrod\Desktop\Akkling-master\examples\../src/Akkling.Cluster.Sharding/bin/Debug/Akka.dll'...
System.FormatException: Unknown escape code: S
at Akka.Configuration.Hocon.HoconTokenizer.PullEscapeSequence()
at Akka.Configuration.Hocon.HoconTokenizer.PullQuotedText()
at Akka.Configuration.Hocon.HoconTokenizer.PullValue()
at Akka.Configuration.Hocon.Parser.ParseValue(HoconValue owner, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
> at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseKeyContent(HoconValue value, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseObject(HoconValue owner, Boolean root, String currentPath)
at Akka.Configuration.Hocon.Parser.ParseText(String text, Func`2 includeCallback)
at Akka.Configuration.ConfigurationFactory.ParseString(String hocon)
at Akkling.Configuration.parse(String arg00) in C:\Users\Snimrod\Desktop\Akkling-master\src\Akkling\Spawning.fs:line 30
at FSI_0003.configWithPort[a](a port) in C:\Users\Snimrod\Desktop\Akkling-master\examples\cluster-sharding.fsx:line 148
at <StartupCode$FSI_0003>.$FSI_0003.main@() in C:\Users\Snimrod\Desktop\Akkling-master\examples\cluster-sharding.fsx:line 154
Stopped due to error
My entire configuration is the following:
let configWithPort port =
let config = Configuration.parse ("""
akka {
actor {
provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
serializers {
hyperion = "Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion"
}
serialization-bindings {
"System.Object" = hyperion
}
}
remote {
helios.tcp {
public-hostname = "localhost"
hostname = "localhost"
port = """ + port.ToString() + """
}
}
cluster {
auto-down-unreachable-after = 5s
seed-nodes = [ "akka.tcp://cluster-system@localhost:2551/" ]
}
# persistence {
# journal.plugin = "akka.persistence.journal.inmem"
# snapshot-store.plugin = "akka.persistence.snapshot-store.local"
# }
persistence{
journal {
plugin = "akka.persistence.journal.sql-server"
sql-server {
# qualified type name of the SQL Server persistence journal actor
class = "Akka.Persistence.SqlServer.Journal.SqlServerJournal, Akka.Persistence.SqlServer"
# dispatcher used to drive journal actor
plugin-dispatcher = "akka.actor.default-dispatcher"
# connection string used for database access
connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
# default SQL commands timeout
connection-timeout = 30s
# SQL server schema name to table corresponding with persistent journal
schema-name = dbo
# SQL server table corresponding with persistent journal
table-name = EventJournal
# should corresponding journal table be initialized automatically
auto-initialize = off
# timestamp provider used for generation of journal entries timestamps
timestamp-provider = "Akka.Persistence.Sql.Common.Journal.DefaultTimestampProvider, Akka.Persistence.Sql.Common"
# metadata table
metadata-table-name = Metadata
}
}
snapshot-store {
sql-server {
# qualified type name of the SQL Server persistence journal actor
class = "Akka.Persistence.SqlServer.Snapshot.SqlServerSnapshotStore, Akka.Persistence.SqlServer"
# dispatcher used to drive journal actor
plugin-dispatcher = ""akka.actor.default-dispatcher""
# connection string used for database access
connection-string = "Data Source=MyMachineName\SQLEXPRESS;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
# default SQL commands timeout
connection-timeout = 30s
# SQL server schema name to table corresponding with persistent journal
schema-name = dbo
# SQL server table corresponding with persistent journal
table-name = SnapshotStore
# should corresponding journal table be initialized automatically
auto-initialize = off
}
}
}
}
""")
config.WithFallback(ClusterSingletonManager.DefaultConfig())
The following line results in the exception that I described:
let system1 = System.create "cluster-system" (configWithPort 2551)
In conclusion, I am new to Akka.Net and am struggling to troubleshoot why this exception is occurring.
It looks like HOCON parser may have a problems with \
and treats it as escaping character. Changing that to \\
should solve the issue.