Closed Amarok73 closed 10 months ago
I'll have a look
Can you post your dcs-code-injector-hook.lua
file here?
By the way, how do You reload whole Moose with the tool? I tried to copy-paste the Moose in the separate tab to drag it down to the buttons, but the tool have hung in paste action...
Alright, I had chance to look at it, but everything seems to work fine using your dcs-code-injector-hook.lua
The file in your Hooks
folder is called dcs-code-injector-hook.lua
and not dcs-code-injector-hook.lua.txt
, right? Can you verify what the actual extension of the file is? Be sure to UNCHECK Hide extensions for known file types
in the folder options:
Can you also send me a "clean" log file by doing the following:
dcs.log
in your Logs
folder to something else, like dcs___.log
, just so DCS will have to dcs.log
fileThat way I can have a look to see what's going on.
Strangely enough, I can't recreate the issue. The only thing different from yesterday is that I've reinstalled the hook file. I've used the "txt" extension on my attachment, as the GitHub do not accept files with "lua" extensions. I'll keep in mind what is needed to investigate the issue, and if it will reappear, I'll try to provide required evidence. For now the issue can be closed. Thank You for Your support, and sorry I have bothered You for vain.
Ok, somehow I've recreated the situation. The log and mission file in attachment. dcs.log.txt Test.miz.zip
It seems, this occurs only when mission started within mission editor.
This runs without any issues on my end. The only main difference I can see between my end and yours, is that you have TacView enabled. Can you try disabling that to see what happens?
Tacview is installed, but disabled in the Specials Configuration menu. The same error I've received just now, on the Normandy Map mission I've created for sightseeing. What is or may be the source of this error? If I'll know the function of this line in the script, perhaps I'll deduce the potential reason.
I'm not sure what would be causing it. That line just sends the string '{"connection": "active"}'
, to the server to let it know the connection is alive. This keeps looping over and over and over again, because the check is happening on every simulation frame.
Can you try replacing the code in the hook file with this, and then sending the log again?
package.path = package.path .. ";.\\LuaSocket\\?.lua"
package.cpath = package.cpath .. ";.\\LuaSocket\\?.dll"
socket = require("socket")
DCSCI = {}
DCSCI.host = "localhost"
DCSCI.port = 40322
DCSCI.time = 0
DCSCI.closed = true
DCSCI.wait = 0.25
DCSCI.mission_load_complete = false
local function reinit_client()
if DCSCI.client ~= nil then
DCSCI.client:close()
end
DCSCI.client = socket.tcp()
DCSCI.client:settimeout(0.0001)
local success, err = DCSCI.client:connect(DCSCI.host, DCSCI.port)
if err ~= nil then
log.write("DCS Code Injector reinit_client -->", log.ERROR, tostring(err))
end
if success ~= nil then
DCSCI.closed = false
end
end
local function init()
log.write("DCS Code Injector", log.INFO, "Starting...")
local handler = {}
function handler.onMissionLoadEnd()
log.write("DCS Code Injector -->", log.INFO, "Mission load complete, Code Injector Loaded")
DCSCI.mission_load_complete = true
end
function handler.onSimulationFrame()
if not DCSCI.mission_load_complete then
return
end
if DCSCI.time + DCSCI.wait < DCS.getModelTime() then
if DCSCI.closed then
reinit_client()
end
-- poke the server, let it know we want some data
local total_bytes_sent, err, index_last_byte_sent = DCSCI.client:send('ac')
if err ~= nil then
log.write("DCS Code Injector onSimulationFrame -->", log.ERROR, tostring(err))
end
if total_bytes_sent == nil then --
if err == "closed" or err == "timeout" or err == "Socket is not connected" then
DCSCI.closed = true
end
end
local response = ""
local chunk, err, partial
repeat
chunk, err, partial = DCSCI.client:receive()
response = response .. (chunk or partial) .. "\n"
until err or chunk == nil
if response:len() > 1 then
-- thanks for this, trampi
local mission_string =
[[
local ok, err = pcall(a_do_script(
[=[
]]
.. response ..
[[
]=]
))
if not ok then
log.write("DCS Code Injector", log.ERROR, err)
end
]]
net.dostring_in('mission', mission_string)
else
if err == "closed" then
DCSCI.closed = true
end
end
DCSCI.dcsci_time = DCS.getModelTime()
end
end
function handler.onSimulationStop()
log.write("DCS Code Injector", log.INFO, "Simulation stopped, closing connection")
DCSCI.client:send('{"connection": "not_active"}')
DCSCI.client:close()
DCSCI.closed = true
end
DCS.setUserCallbacks(handler)
log.write("DCS Code Injector", log.INFO, "Load OK!")
end
local ok, err = pcall(init)
if not ok then
log.write("DCS Code Injector", log.ERROR, "Error loading Code Injector: " .. tostring(err))
end
If you have an extra firewall, like Norton or something like that, can you try shutting that off to see if it makes a difference? Looks like the socket times out on trying to connect to localhost
... which is very weird.
If you don't have an extra firewall, first try changing this line
DCSCI.host = "localhost"
to
DCSCI.host = "127.0.0.1"
If that also doesn't work, try changing this line from
DCSCI.client:settimeout(0.0001)
to
DCSCI.client:settimeout(0.001)
and see if that solves the issue.
The way data is fetched now from the server is not ideal because DCS is just constantly polling the sever in the Python program and that takes quite a hit on FPS as well. I need to take a look how to implement this in a better way I think
So far, disabling NOD32 and system firewalls on all three categories (local, domain and public) gave no effect. In meanwhile I've had an idea to check the localhost itself, so I've pinged my computer from my computer and here's the outcome:
Then checked the hosts file:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
# Added by Docker Desktop
192.168.1.104 host.docker.internal
192.168.1.104 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
... I'll try now with other settings in the hook file...
"We have a new symptom", as dr House would say. Netstat shows as follows: ...and this relates probably to something like this in the log file: dcs.log
Well, I've cleared-out hosts file from everything except pointers to the localhost at address 127.0.0.1 and... it works! No more errors related to the connection timeout. 8-| Can't see really what could fix the situation though...
Hello,
The hook script seems to cause reporting errors as follows: But I can't see any issue whit the reported part of the code. Is it something that should I be worried about?