Revisiting Fixing Valheim Lag – Modifying Send/Receive Limits

My Valheim Dedicated Server Castle
My Valheim Dedicated Server Castle

I’ve previously covered fixing Valheim’s dedicated server lag by modifying the dedicated server’s send receive limits. Since I wrote that article not long after launch though the game has been updated that the old method no longer applies. I had theorized in the comments of that article how to address this and today Sam R. confirmed that this method did indeed alleviate most congestion on the server in the places that the send/receive limits are known to bottleneck.

This updated guide will show some updated methods you can use to help reduce lag on your Valheim dedicated server!

Symptoms of lag on Valheim dedicated servers

The symptoms you are experiencing on the server can help narrow down what type of lag you are experiencing and what may be causing it. Lag caused by your CPU being too overloaded for example will have different symptoms than lag that is caused by your server hitting the maximum send/receive limit as an example.

By far the most common type of dedicated server lag seen in the early access Valheim release so far has been mainly due to the low send/receive limit if 64KB/s that is hard coded into the server. This means that when you do something like take your character a heavily populated area on the server it has to send all that information about all the buildings/players through an artificially limited very narrow 64KB/s pipe.

Symptoms of the send/receive limit type of lag include things like chests taking a very long time to open, sometimes 10-30 seconds or never opening while at the same time being able to see players walking around normally. This is because the other people’s X / Y / Z positions is a very small amount of data compared to all the items/names/attributes that are stored in the chest. The other players moving easily fits through the narrow pipe while the chest full of loot’s data chokes since it is much larger.

I’ll specifically lay out how to modify your server and increase this limit in the “Modifying your server’s send/receive limit” section below. Before that though let’s cover a more specific type of lag to watch out for (mostly by being avoided) related to terrain manipulation.

Avoid extensive terrain manipulation (for now)

Another commonly observed source of lag has to do with terrain manipulation. Some players have found that if they take a big chunk out of the ground in Valheim and make extensive terrain modifications that the area gets filled with separate “instances” of terrain for each modification people make. Think of the original ground as one big piece in the game files. Valheim has the very cool feature of letting you modify terrain by raising it/lower it/level it/etc. Each time you do this though the game has to store what you did as a new “instance” or a modification.

The way Valheim seems to work now is it renders that original piece and then the modifications afterward. Early reports suggest having a whole bunch of them in one spot seems to sometimes cause everyone’s in-game FPS on the server to drop as low as 40 when the clients normally are much much higher than that.

The best way to avoid this type of lag at the moment is to limit how much terrain modification you are doing in areas near your base. It is likely this will be addressed/eased in future patches. There should be some things the developer team can do to clean up/merge these instances or at least reduce their effect on the rendering process so it doesn’t drop the in-game FPS so dramatically.

Modifying your server’s send/receive limit

At this time there is no options file for Valheim unfortunately. The only way to change it is to modify the server’s code and recompile the module that controls this.

Fortunately this is a lot easier than it sounds because the module we need to change is in .NET instead of something like C++ which would be much more difficult to do this with. I did not come up with this method, a very clever user on reddit (maximgame) shared it here and I want to give credit where credit is due!

Despite it not being too difficult these modifications are at your own risk. I haven’t experienced any problems so far but technically we are modifying the server’s code with the following procedure so understand that this isn’t an officially supported method and could have side effects or if you make a mistake could cause serious problems. Make sure you have backed up everything (your game world files especially) before you try anything!

Another important note is that it’s very likely you will have to make the changes again each update since the file we are going to modify is going to get replaced by updates. Until they add either a launch option or options file to officially change/control this property that is unfortunately unavoidable.

With all that being said if you understand the above and still feel comfortable let’s proceed!

Get dnSpy utility

We are going to use the utility dnSpy to modify the server code and recompile the module. The utility is free and is available here (download the Win64 build or dnSpy-net-win64.zip): GitHub dnSpy Official Page

Extract the archive and run the program dnSpy.exe from inside the folder you extracted. The dnSpy application will open.

Modifying server with dnSpy

We are going to go to the “File” menu in the top left and choose “Open” like this:

dnSpy - File -> Open Menu
dnSpy – File -> Open Menu

Now you need to navigate to the Valheim dedicated server folder which is located in your “steamapps” folder. If you left all the options default when you installed it’s typically “C:\Program Files (x86)\Steam\steamapps\common\Valheim dedicated server\valheim_server_Data\Managed”.

We are looking for the file “assembly_valheim.dll” in that folder:

dnSpy - Select File
dnSpy – Selecting Valheim server assembly file

Select the file “assembly_valheim.dll” and click “Open” and the server’s assembly will load into dnSpy.

Once it has finished loading we are going to go to the “Edit” menu and click “Search Assemblies” like this:

dnSpy - Search Assemblies
dnSpy – Search Assemblies

For the search criteria enter “ZDOMan” like this:

dnSpy - ZDOMan Search
dnSpy – Searching for ‘ZDOMan’

After the search completes you should see a list of results like the one above. Double click on one of these entries on the list and it should place you in the ZDOMan section of the assembly (seen on the left hand side of the screen):

dnSpy - 'ZDOMan' section of assembly
dnSpy – ‘ZDOMan’ section of assembly

Perfect. We are now in the right place to make the changes. We just need to locate the line that has the send/receive limitation. To find that press Ctrl+F to bring up the find box (or choose “Edit” -> Find from the menu) and search for:

 sendQueueSize

which should bring up the following lines:

dnSpy - sendQueueSize Variable
dnSpy – sendQueueSize Variable

If you are having trouble finding the lines make sure you’re using Ctrl+F to search this time and not the “Search Assemblies” from earlier at the bottom of the screenshot, that’s a different type of search. Make sure you’ve disabled the case sensitive options (the Aa right below the box) or any other search filters. Your search query box should be in the top right of the screen like the above screenshot that has sendQueueSize in it.

Now right click on this line:

int num = 10240 - sendQueueSize

and click “Edit Class (C#)…”. Another window will open that will let you make changes to the file. We are going to modify ‘10240’ to a variable of our choosing. I made mine 30720 since after doing some conversion math that is the equivalent increase from my previous launch version guide that provided great performance and I kept them the same. If you followed my last guide this will give you the exact same performance as the old one did.

There are two instances of this variable. The second instance is 3 lines above the highlighted line we searched for and is:

if (!flush && sendQueueSize > 10240)

Modify both instances of 10240 to 30720.

Theoretically setting a limit too high could cause the server to swamp your internet connection if you have a large number of players on and there’s essentially no limit but there shouldn’t be any other effects of a very high number.

Once you’ve changed both numbers to the desired value we need to press the “Compile” button in the bottom right corner of this new window. This window will close and take you back to the previous one.

Saving the new assembly

It’s time to save our changes into a new .dll file. Choose “File” -> “Save Module…”:

Saving New Assembly
dnSpy – Save Module as assembly_valheim_modded.dll

Change the file name to assembly_valheim_modded.dll. Don’t overwrite the original file just yet as we will want to take a backup and make sure that the server is closed before we do that. Press “OK” to write the new assembly_valheim_modded.dll file.

Backing up original file and replacing with our new one

Now it’s time to back up the original file and replace it with our new modded file. First make sure your dedicated server is closed otherwise the dll file will be in use. It is also a good time to make a backup of your world file just in case (see my Valheim Dedicated Server Backup Location / Guide for instructions)

Navigate in a file explorer window to your Valheim server directory where we saved the new assembly file (usually C:\Program Files (x86)\Steam\steamapps\common\Valheim dedicated server\valheim_server_Data\Managed).

First make a copy of the original assembly_valheim.dll file. You can just select the file and “copy” then paste a copy of it in that same folder and Windows will make a “valheim_assembly Copy(1).dll” file for you or you can back it up to a separate folder. Now remove the original file and rename your “valheim_assembly_modded.dll” file to the original file name of “valheim_assembly.dll”.

That’s it, you’ve now replaced the old assembly with the new one! Go ahead and start your server normally and the changes will have taken effect.

Other Resources

Make sure you are taking constant backups of your Valheim dedicated server: Backup Valheim Dedicated Server – World Folder Paths / Guide

It’s also important to back up your local game’s characters and local worlds if you are using them. I have written a guide for the local game side that is available here!

For historical reasons I’ve left up the post with the old method here as it helped me devise the new method: Fixing Valheim’s dedicated server lag by modifying the dedicated server’s send receive limits

Other Valheim Lag Issues

If you know of other Valheim lag issues that I didn’t cover here or are still having problems let me know in the comments and I will update this guide with other tips/tricks and try to answer any questions. It’s still a very new game and there isn’t very much out there for it yet. Have fun and enjoy!

Subscribe
Notify of
guest

252 Comments
Inline Feedbacks
View all comments
David C Burkhart
David C Burkhart
3 years ago

Hey jameachambers!
I have attempted to follow this guide to the letter and I get to the point where it is time to “compile”, dnspy spits out a number of errors such as: cs1001, cs0246, cs0103, cs0012 on a huge number of lines.
some perliminary reading and looking at the errors themselves, it appears that a bunch of references are lost. I get these errors even if I don’t change anything and atempt to compile.
I am only just beginning to dabble in this stuff and am sure there is a magic switch somewhere I am not flipping before starting.

Maybe this will be seen in the RIGHT place this time XD

David C Burkhart
David C Burkhart
3 years ago

I will have someone else look at it. I don’t see how my OS would be corrupt. I don’t generally get any windows errors and the computer is installed with a licensed OS.
Maybe when I get home from traveling I can try it on my wife’s computer.

Thanks for the answer back!

David C Burkhart
David C Burkhart
3 years ago

So! after some messing around with one of my server admin colleagues:
We discovered the reason why I was unable to compile the assembly after editing the class was because we were pulling the .dll out of its native directory, the references the error codes alluded to was it’s sibling files in that directory. Once we placed the assembly_valheim.dll back into its home, we were again able to make the changes prescribed in your article. We are all extremely new to .net stuff so we were ignorant. Now that it is edited, it can then be transferred to the dedicated gportal server.

Thanks for the interaction!

Kurti
Kurti
3 years ago

Thanks alot for the follow-up.
This helped me alot because I did the same mistake to only copy the one file onto my PC in order to change the .NET code.

GregR
GregR
3 years ago

My understanding is that this happens if you try to edit the assembly_valheim.dll file in a folder by itself. You need to edit it in place in the valheim_data (or valheim_server_data if you’re editing the server dll)\managed folder, with all the other files in place or you get errors because it references those files.

David C Burkhart
David C Burkhart
3 years ago
Reply to  GregR

just saw this! Thanks for the answer back. it seems all I had to do is read further XD

patk88
patk88
3 years ago

Hi James,

Thanks for this guide, once we implemented this guide with a lot of mods installed our send and receive caps out at 150kb/s and when this happens we get massive desync.

After a bit of researching online with my brother we have discovered some other settings that are limiting the transfer speeds:
Note: we have to edit both the client and the server valheim_assembly.dll, as these are different make sure you select ‘close all’ in dnSpy before opening the next .dll
-Server dll: Search assembly for ‘zSteamSocket’ and find ‘RegisterGlobalCallbacks’ and edit the class.
-add an extra 0 for the number in ‘gchandle3’ (set to 1536000)
-add the following line just before ‘gchandle.Free();’

SteamGameServerNetworkingUtils.SetConfigValue(ESteamNetworkingConfigValue.k_ESteamNetworkingConfig_SendBufferSize, ESteamNetworkingConfigScope.k_ESteamNetworkingConfig_Global, IntPtr.Zero, ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32, gchandle3.AddrOfPinnedObject());

-Now compile, and save the dll and select ‘Close All’

-Now open the client dll and do the same thing but the line will be this instead:

SteamNetworkingUtils.SetConfigValue(ESteamNetworkingConfigValue.k_ESteamNetworkingConfig_SendBufferSize, ESteamNetworkingConfigScope.k_ESteamNetworkingConfig_Global, IntPtr.Zero, ESteamNetworkingConfigDataType.k_ESteamNetworkingConfig_Int32, gchandle3.AddrOfPinnedObject());

Once we did this we no longer had a cap of 150kb/s

patk88
patk88
3 years ago

Good Evening James,

I did a bit more testing, turns out I got something wrong in the server .dll config, I kept getting errors in the server console about the maximum buffer size being 524288 bytes. Anyway I need to do more testing but I restored both the client and server dll files and then I edited both of gchandle3 lines to:

GCHandle gchandle3 = GCHandle.Alloc(524288, GCHandleType.Pinned);

I suspect that this is all we need to change in the dll files to get better a connection / sync (if I increase the 10240 number as above the average data sent to the server appears [for the same areas] to increase compared to not changing it). I didn’t have anyone to test this theory out with today, but I think it looks promising from the single player tests I’ve done with lots of instances loaded.

patk88
patk88
3 years ago

Hi James,

I have done a bit more solo testing, from my tests the line:

GCHandle gchandle3 = GCHandle.Alloc(153600, GCHandleType.Pinned);

Is indeed the speed cap (as reported by the F2 statistics, unsure if they stats page is actually accurate however), as if I raise it to something like 524288 the send speed can now exceed the 150kbs cap that appeared to be present before (and this is with no other changes to the .dll).
Now given this single change appears to uncap the speed, it stands to reason that the same change in the server .dll should do the same thing (although I haven’t been able to test this theory as I will need to have 3-4 other players online with me).

My speculation is that the server isn’t processing any of the data it is receiving from the clients, it just receives it and then sends it off to the clients that are within range of the client who sent it (basically like p2p just via a server). What I think is happening when fighting a boss like bonemass with 3-4 players, is that the data coming in from each client is exceeding the servers capacity to forward it on to each client… so if each client was sending 80kbs of data the server would need to send 240kbs back to each of the clients (3 * 80), because the send limit is 150kbs the events start queuing up until the server can get to them, and with a larger queue this is made even worse because there is potential for more out of sync data to be sent rather than be discarded.
With this in mind I think that for servers that the player base has low speed uploads (DSL etc) you may want to reduce the queue on both the server and the client, but for those servers where the players have decent upload speed I think increasing the queue (maybe only x2-x4) and lifting the send speed limit. Not sure if what I am saying is true, I am not super familiar with C# I am just speculating based on observation.

Cheers.

patk88
patk88
3 years ago

Hi James,

Thanks for explaining that, that definitely appears to match what I am observing.

So i did some testing with 2 others just now (3 of us in total) fighting bonemass… which is a boss that has never been smooth. On both the server and the client .dlls I changed the queue size to 15360 (15kb) and the sendratemin/max to 524288 (512kb) and then distributed the .dlls to the other clients and the fight went flawlessly, there were lots of slimes and AOE animations going off everywhere and we never saw any signs of desync and we all could agree where the boss was throughout the fight. I also had the F2 menu up the whole fight and the receive rate would occasionally hit ~160 to 170kbs for a couple of seconds and then settle out around 130 mostly.

Hopefully this weekend we can try it again with a couple more players, but the results so far look promising.

GregR
GregR
3 years ago
Reply to  patk88

If you want to share your modified dll’s, I’d be happy to jump in and help you test. I’m running Epic Loot 0.8.4 and my character is just about ready to fight Bonemass. My dedicated server has been having issues running more than 2 people with Epic Loot, so I’d love to get a fix for that.

patk88
patk88
3 years ago
Reply to  GregR

Hi Greg,

After a bit more testing the settings we found that work best for us is to set the send queue to the size recommended in this article (30720) on both the server and the clients, and the sendratemin/max to 524288. This has by far given us the best results yet.

After a bit more googling I found a reddit post from way back that gave a good analysis of what the updated code is doing:

For your reference all of our players have at least 50/20 mbps internet connections and the game is running very well now with 3-4 players in a single area.

Nyanha
Nyanha
3 years ago
Reply to  patk88

Hi patk88
I’m bad at this.
Can you explain more clearly?
You just need to change the value of gchandle3 to 30720. And where do you change the sendratemin/max entry?

GregR
GregR
3 years ago
Reply to  Nyanha

If I may… I think he’s saying that you need to follow the instructions in the article above to set “sendQueueSize” to 30720 on server and client, and then set “GCHandle.Alloc” to 524288 on both server and client, as well.

GregR
GregR
3 years ago

I thought that was what Patk88 was saying he’s tried and achieved great results on? He said “After a bit more testing the settings we found that work best for us is to set the send queue to the size recommended in this article (30720) on both the server and the clients, and the sendratemin/max to 524288. This has by far given us the best results yet.”. Granted, maybe I misinterpreted “sendratemin/max” as “GCHandle.Alloc”, because I wasn’t 100% sure that’s what Pat was referring to, but based on an earlier post, I thought it most likely. We previously set our server’s queue size to 30720 as stated in the article, but hadn’t modded our client .dll’s. We got slightly improved performance, but still had desync bad enough to not be playable with more than 2 players. Strangely, it doesn’t appear to be a latency issue for us, two of us are on the same LAN as the dedicated server, with a gigabit connection to the internet, and the third player is on a separate gigabit connection. I think that the server simply can’t handle all the extra data associated with Epic Loot. Anyway, I made changes to the dll’s as I indicated above, I’ll try that out this evening and post results.

GregR
GregR
3 years ago

I get what you’re saying. I’m in IT also, have been for 20+ years. I’ve already done all of the low-level stuff to try to fix the issue. Swapped physical servers, rebooted routers, added RAM, reinstalled dedicated server software, etc. Nothing seems to help. I’m on a fiber 1gbps connection, and so is our remote player, so bandwidth is definitely not the issue.

The thing is, we DIDN’T have desync issues with vanilla (unmodded) Valheim. We were able to play through the whole game with 6 people on the server playing together. I’m almost certain the issue (and it’s widely reported) is with the Epic Loot mod for Valheim. We’re trying to do a second play through with that mod installed because it adds new content, which the Iron Gate devs aren’t doing very quickly. I’m almost certain that the issues are caused by several players with lots of “enhanced” gear, which the game apparently has a hard time keeping track of.

Anyway, I’m just hoping that the changes Pat suggested will work for us. I’m going to try to ight, I’ll post back with results. Thanks for hosting this discussion, either way!

Zarien
Zarien
3 years ago
Reply to  GregR

Hey GregR, I think you’re on the right track. We’re running into the same issue (fellow IT Manager/Networking Specialist) and this has been driving me nuts. No issues on our vanilla unmodded server, tons of issues when we added the mods recently.

I’ve made the original changes that james mentioned and saw no significant improvements when we added more than 2 players. I’ll be really interested in seeing your results and if you had any improvements tonight. I’m pulling my hair out looking for a way to improve this, because I know it’s not my hardware/1gbps fiber line either, and the headless client itself is barely touching my insanely overkill hardware.

Please let me know if you we’re able to get this to work!

Zarien
Zarien
3 years ago

It’s been confirmed this is stemming from Epic Loot in the forums/post discussion for the mod recently. I’m just looking for a modification, even if required for both client and server, that will allow for the desyncing to not occur despite the overloading of information coming from the recently poor gear characterization data from the mod, because most of us are revisiting the game for the flavor it brings to the table.

GregR
GregR
3 years ago

We’re using 0.8.4, the latest version on Nexus and also on Github. Epic Loot really adds a ton of replayability to the game. If you haven’t tried it out, it’s definitely worth a shot.

I did notice that there’s an issue reported on the Github page that would seem to identify a root cause (or at least a contributing factor) for the desync issues. Could be a clue for those of you who code!

GregR
GregR
3 years ago

Sadly, my testing didn’t happen tonight, life got in the way. Hoping for better luck tomorrow.

As for what makes me suspect it’s the TCP stack, I’m kinda just grasping at straws at this point. The desync makes me think that the net code is getting overwhelmed by too many objects, and I’m thinking that could be alleviated by opening things up. I’m not a coder, I’m just hoping this works!

GregR
GregR
3 years ago

OK, so, I still didn’t get a chance to test fully. My wife’s machine decided to have a boot issue that I now have to sort before she can play. In better news, however, both the server and the one client who did manage to play last night had modded dll’s (SendQueueSize AND GCHandle.Alloc) in place, and the player said he didn’t have any issues, everything seemed stable. He was able to fight and got some loot drops. I’m hoping we can test with more clients tonight, but no promises.

GregR
GregR
3 years ago

We finally got to try it out tonight. Seems to work really well. We fought a ton of Draugr, Fuling, Skeletons, etc. Three of us in one area, all with lots of epic/legendary gear, no desync. I’ll continue testing, but it sure looks like this fixes the problem!

patk88
patk88
3 years ago

Hello Guys,

We have also been running since the last post I made about the queue size and sendratemin/max fine with 3-4 people playing in the same area.
The extra data does indeed seem to be caused by EpicLoot… which is a mod that we just can’t do without.

I did a bit more googling and it seems that a while back someone made a network compression mod for valheim a few versions ago which could alleviate much of the extra data.
Unfortunately it no longer works with the current version, if you are interested the link to it is here.

Also for anyone wondering how we manage clients, we are just using onedrive and a script to keep everyone’s client up to date (sync the directory).

GregR
GregR
3 years ago

What I’ve read (and again, I’m not a programmer) is that the Epic Loot mod is syncing information between all clients to keep track of non-standard information like item enchantments and enhancements, and that that is creating a bunch of additional traffic that isn’t necessary when you’re just playing vanilla Valheim without the Epic Loot mod.

Stepan
Stepan
3 years ago
Reply to  patk88

Good afternoon! I’ve been reading your comments for the third day now, and I’ve been trying to stabilize my server for about a week. I’m not a programmer, I just want to play a game with my friends without desynchronization. Please, could you send me both files (dll for the server and dll for the client) by email I would be immensely grateful to you, my life turned into hell while I was looking for a solution to this problem, but I never managed to fix everything!

King
King
3 years ago
Reply to  patk88

Hi Pat. I will try this tonight with 5 or 7 players in same area.

GregR
GregR
3 years ago
Reply to  King

Were you able to try this out? If so, how did it work for you?

King
King
3 years ago
Reply to  GregR

Hi. I think combining james and patk ideas changing SendQueueSize and GCHandle.Alloc to their specified values helped. data rcv increased upto 250. but…
With mods such as epic loot (this mod is in demand, maybe there are others causing issue), playing with 6 players that scrambles in 1 area, desync is inevitable at some point. host and clients keep on changing, instances merging (it’s not fun to stay in 1 area to maintain host), etc.

the fact that not all has good latency. It’s a hassle, determining verbally with others who is host and if they can portal in and out the area so others can be host, whichever has good ping result.

Btw, we are combination of wired/wireless and fiber/4g/cable. mostly it is the cable guy causing issue and sometimes 4g folks. They are my friends so I can’t kick. haha

Sorry for non technical feedback but I hope it helps. probably if you have situation like me, follow the fix here. then avoid using mods with demanding packets, data sent/rcv or whatever. Also bookmark this page.

GregR
GregR
3 years ago
Reply to  patk88

What mods are you guys using? We use Epic Loot and CLLC, and we have been having huge desync issues with just three players. I’m desperate to find a fix, I love the game, and this combo of mods makes it worth playing through again after having beaten it on vanilla.

unkske
unkske
3 years ago
Reply to  patk88

This fixed the issue in my server, both gchandle3 and sendqueuesize changes did the trick. Now it’s up to 305kb/s per player, which probably explains the desync when it was limited to 150kb/s.
I’m also using a lot of mods but, as reported in Epic Loot forums by other players, that mod alone is the one causing the problems. Someone said that when up to 6 players there is still desync happening, maybe try using a higher value in sendqueuesize if you see the receive speed close to the limit (some of you guys who know better maybe can correct me)

Thank you all for taking the time to share this info, it helped me and my friends a lot and now we can continue to enjoy this game. The mods really add tons of new gameplay features, we are using Epic Valheim v3.0 mods pack if anyone interested.

King
King
3 years ago
Reply to  patk88

I followed James and pat instruction on a dedicated server. I don’t see server error logs, but I can only see lands and mountains. no trees, creatures, etc.

King
King
3 years ago

Visiting this page often. Thank you

patk88
patk88
3 years ago
Reply to  King

Hi King,

Yes I ran into this issue as well, the thing I initially posted works only on the client .dll (turns out when I attempted to edit the server .dll i ended up searching the already open client .dll and didnt end up changing anything). For some reason when you change the server .dll it doesn’t send any data to the client (hence the land with no trees or structures).

I am still investigating down this route as I can see in the F2 display that when I change the client .dll the send speeds go from being capped at 150kbs to seemingly not having a cap (most I have seen so far is about 290kbs). I will post back here once I know more, this may take a few days because it is challenging to organise 2 to 3 other people to do some testing around work and home commitments.

One of the things I am wondering about at the moment is that increasing the queue size too much may result in too many past actions queuing up once the client hits the send cap, which could be causing the desync to get worse as it will have quite a large backlog of past events to send to the server and the newest events won’t get sent until the queue clears out…. this is only speculation based on observation though I’m not sure if that is what is happening.

And for anyone wondering I running Valheim with a lot of mods (probably 20-30 mods), with Valheim+ and Epic loot being the main ones.

King
King
3 years ago
Reply to  patk88

Same here. Please make sure you are using latest epic loot as older versions are causing what it looks like desync. really appreciate you trying to fix it along with James. thank you so much guys

GregR
GregR
3 years ago
Reply to  King

The latest (0.8.4) version of Epic Loot still has desync issues. A guy on the Nexusmods forums for the mod had this to say:

“All out of sync from the terrible logic of syncing things between the player. All players are constantly exchanging with all packages with their things. This is necessary to highlight enchanted items on the player.
This logic clogs up all traffic. If usually ~ 20 kb, then with a mod ~ 80 kb per second. 1 The player weighs 0.1 mb.
Such a huge weight is achieved by the same terrible logic of Extended Items Framework. Tens of kilobytes of garbage are simply recorded in the field “CreatorName”.”

I don’t know if that’s accurate or not, but it certainly seems to jive with what we’ve been seeing, in that 1-2 people with lots of “enhanced” gear on can be in an area without issues, but the moment the third person shows up, it’s desync city. I’m hoping that some netcode optimization like what’s being discussed here will help.

patk88
patk88
3 years ago
Reply to  GregR

Hi Greg,

See my reply to your other message which has our current settings, we have all these mods installed and running with 3-4 players in a single area… the data receive rate does sometimes get into the 300kbps per client when there are a lot of monsters running around though (We have a physical server with on 1000/50 connection, so you may want to keep this in mind depending on where your server is being hosted).

Norby007
Norby007
3 years ago
Reply to  patk88

So our group has been dealing with a lot of bad lag. 50+ mods but it really kicked in after adding Monsternomicon. Going into new areas or getting a lot of mobs in the area at the same time would cause stuttering, teleporting, or invisible mobs. It was fine alone and when my friends played together they were fine. It would only fail when I joined. Their pings are 15-40ms and mine is 80-90 due to distance. It really seemed that this difference in ping time was the issue because even one other player and me on the server would cause it to lag. But 2 or 3 of them together was no issue.

I first tried setting some of the mods back. I tried premade work arounds that I now know are outdated. I found this walk through and tried the buffer extension above. No luck. But then after rereading this cap change from Patk88 I finally gave it a whirl. I added it to the server and the clients and zero issues now. Even mods like the seed totem that would show a delay when hitting the totem to pop the vegetables is gone. We hit the server heavy using everything we had at once and no hiccups.

Absolutely amazing Patk88! Bravo!

Thank you!

While I am no stranger to programming, it is not my line of work. I would suggest making a guide like the queue changes to make it easier for others to make this modification. It appears stable and without issues.

Norby007
Norby007
3 years ago

I agree it’s an issue with the mods themselves and for the ones we like the best there are no other options. This modification has continued to work seamlessly. I did see a couple times the server ram fill up all the way. It’s rare and I restart it when it happens. It only happens with the mods active. I imagine there is also a memory leak somewhere.

K S C
K S C
2 years ago
Reply to  patk88

I can’t find this field, but I’ve also never used DNspy and this is one of the most complicated interfaces I’ve ever used.

Tomm
Tomm
3 years ago

After I modded the DLL the game no longer starts. It works with the original DLL. The error message I see is:

Jul 23 13:08:32 valheim valheim_server.x86_64[2772]: (null)/.steam/sdk64/steamclient.so: cannot open shared object file: No such file or directory
Jul 23 13:08:32 valheim valheim_server.x86_64[2772]: [S_API] SteamAPI_Init(): Sys_LoadModule failed to load: (null)/.steam/sdk64/steamclient.so
Jul 23 13:08:32 valheim valheim_server.x86_64[2772]: [Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.

Searching for steamclient.so:
locate steamclient.so
/home/steam/.local/share/Steam/steamcmd/linux32/steamclient.so
/home/steam/.local/share/Steam/steamcmd/linux64/steamclient.so
/home/steam/Valheim/linux64/steamclient.so
/home/steam/Valheim/steamclient.so

Switched back to original DLL and it worked again. Running Ubuntu 21.04. Did the modifications on my Windows PC and then uploaded the DLL and set the original owner and file rights (steam:steam / 755).

Any ideas?

rufi0
rufi0
3 years ago

i’m just curious, since it’s not ever explicitly touched on in this guide or on the original reddit post, but what does the 10240 actually refer to? rather, how does that translate to the kbps that most people refer to?

rufi0
rufi0
3 years ago

oh my gosh, thank you so much for that thoughtful and in-depth response! i was able to edit my server to sam’s 102400 below, and it seems to have alleviated much of the lag we experienced when we had 6 people online at once. i did experience the chest lag a couple times during our recent session, though that may have been attributable to some internet issues a couple of us were having at the time. i’m also thinking about compiling and sending an editted .dll to each user to see if that helps – since some of the users on the original reddit post had also tried it, and especially considering the next boss we have to tackle as a group is bonemass. any thoughts/recommendations in that regard?

werner
werner
3 years ago

‘When i put the modified dll in my server it does not start. I’m running my server on docker on a linux 18.04.

I’m getting that on server log:

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 39)
[PrefabCreator] Added recipe: Recipe_FreezeGlandDrakeTrophy
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 39)
Unloading 92 unused Assets to reduce memory usage. Loaded Objects now: 92036.

Total: 139.312885 ms (FindLiveObjects: 5.078719 ms CreateObjectMapping: 15.522041 ms MarkObjects: 117.656501 ms DeleteObjects: 1.048291 ms)

Setting up 2 worker threads for Enlighten.

Thread -> id: 7fd30f7fe700 -> priority: 1

Thread -> id: 7fd30effd700 -> priority: 1

07/09/2021 10:36:34: Steam manager on destroy

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 39)

werner
werner
3 years ago

So, i reinstalled everything and tried again, it worked. Now i will see if it can help us.

Thank you for the attention and for the article!

David Taylor
David Taylor
3 years ago

I had the same problem as werner. The problem was modding the client DLL instead of the dedicated server DLL. They are different, and only the server one can work in dedicated server mode. Starting with the dedicated server Managed directory instead of the Valheim client directory fixed it.

Frank
Frank
3 years ago

I’m currently trying this method. Don’t seems to make a difference for now though. Maybe my values are not high enough, I don’t know. It’s like in the 200000 for the client.

Sam Ramji
Sam Ramji
3 years ago

You are too cool!

I am currently running 102400 as the “magic number” and it appears stable, but more multiplayer testing is needed.

A few other server admins are testing this out as well (you can find them over at Valheim Modding in the #user-assistance channel). We are all grateful for your help!

1 2 3 8